Tweak155
Lifer
So basically my goal is to disable Immediate Window access in.... Access.
I "compile" the MDB into an MDE but a savvy user can use the MDE Immediate Window to do things I don't want them to do.
After researching and seeing that there is no multi-threading in VBA (so I can monitor the windows the user opens), I found an idea about kicking off a VBS that can infinite loop and check for the VBA editor and whether or not it is open.
I want my "infinite" loop to end when it detects that Access is no longer open.
So basically it will work like this:
User opens the MDE
MS Access will write a VBS to the user's system and execute it.
This VBS will scan every second for the VBA editor
If the VBA editor is open, it will force close it (through SendKeys)
Once MS Access is closed, the script self terminates.
The "tricky" part to this is I want to look at the application title to determine when to close - since I will always know the title and it should be unique. Maybe I can pass the application handle to the VBS, but even then I'm not sure how to check if that handle is simply open.
I've simulated the loop with the following:
Problem is this activates the window as my check - so if they go to use another application, it will keep bringing the Access app to the forefront. Looking through the WIN32 classes I can't find one that will suit my needs.
Any ideas?
Thanks.
I "compile" the MDB into an MDE but a savvy user can use the MDE Immediate Window to do things I don't want them to do.
After researching and seeing that there is no multi-threading in VBA (so I can monitor the windows the user opens), I found an idea about kicking off a VBS that can infinite loop and check for the VBA editor and whether or not it is open.
I want my "infinite" loop to end when it detects that Access is no longer open.
So basically it will work like this:
User opens the MDE
MS Access will write a VBS to the user's system and execute it.
This VBS will scan every second for the VBA editor
If the VBA editor is open, it will force close it (through SendKeys)
Once MS Access is closed, the script self terminates.
The "tricky" part to this is I want to look at the application title to determine when to close - since I will always know the title and it should be unique. Maybe I can pass the application handle to the VBS, but even then I'm not sure how to check if that handle is simply open.
I've simulated the loop with the following:
Code:
Set oShell = CreateObject("WScript.Shell")
While oShell.AppActivate("App Title")
If oShell.AppActivate("Microsoft Visual Basic for Applications") Then
WScript.Sleep 500
oShell.SendKeys "%{F4}"
End If
wscript.Sleep 1000
Wend
Problem is this activates the window as my check - so if they go to use another application, it will keep bringing the Access app to the forefront. Looking through the WIN32 classes I can't find one that will suit my needs.
Any ideas?
Thanks.
Last edited: