execScript (JavaScript) throws Access Denied Error in VBA (1 Viewer)

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
On some machines I receive the Error: "Access is Denied" Error #: -2147024891 when initiating JavaScript from within VBA.

Call Forms("frmMap").WebBrowser.Document.parentWindow.execScript("initialize()", "", "JavaScript")

Is this a security setting in Internet Explorer ? I don't have much access to the machines that experience this error so I am looking for any clues before I ask for some time on the machines.

I did a quick google search and didn't really come up with anything for VBA and MS Access.

Thanks.
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
Well as the message implies I would imagine this is a security measure. I wouldn't imagine anyone can just execute any script on a website, that would be dangerous.

I'm sure it would work if the script was local.
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
I wrote the JavaScript. It's embedded in an HTML file that I created which is embedded in a Web Browser Control on an MS Access form. Typically there is no issue but on some machines I get the mentioned error.
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
Can you see a pattern with the OS or browser type/version?
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
It happens on some Windows 7 Pro machines but generally works on Windows 7 Pro Machines. I am going to play around with IE security settings to see if I can reproduce the error on my Windows 7 Machine. I get very little time with the machines that actually generate the error since they are on Managers machines. I was hoping someone may have encountered this before to give me a head start.

Thanks
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
My IE 11 security settings were on Medium and there was no problem executing the JavaScript from VBA. When I put the Security settings on High I did get an error but it was thrown from within the Script meaning the script executed.

The original error is thrown by VBA and the script doesn't even commence. So it's not the Security settings in IE 11 based on this test. What could it be then?
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
Nothing to do with VBA. The script is being executed from within the Web Browser control which runs IE. The control is simply an extension of IE from which VBA code can be parsed. Errors of such nature are thrown by IE and caught in VBA.
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
I disabled every scripting setting in IE 11 and surprisingly the JavaScript starts but I get the same error as on High settings shortly after the JavaScript executes. That is not what I expected.
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
vbaInet,

The error thrown on my machine is thrown by IE not MS Access. The dialog is an IE dialog. The error that my users experience which I cannot reproduce is displayed in a standard VBA msgbox. I don't believe the javascript even executes on the user's machines but in my case it does.
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
Have you tried running it through DOM?

The original error "Access Denied" is triggered when VBA tries to execute the below call. I am not fully certain how running it through the Document Object Model would assist. Please note that at medium IE 11 security settings I don't experience any errors on my machine running the same OS (Windows 7 SP 1) as the other users.

Call Forms("frmMap").WebBrowser.Document.parentWindow.e xecScript("initialize()", "", "JavaScript")
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
Can you throw up a test db? I'll test it on my end.
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
vbaInet. I'll try to prepare something for you tomorrow. It's time for bed here.

Thanks
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
vbaInet,

I contacted a colleague who uses similar code / JavaScript and he said he experienced the same error sometimes. He couldn't explain it but his recommendation was to make a copy of the HTML file and replace the original. That sometimes fixes this error for him. I will give this a try and let you know if it worked.

Thanks
 

ions

Access User
Local time
Today, 08:21
Joined
May 23, 2004
Messages
785
I swapped the HTML file that had the embedded JavaScript and the error persists.

One one machine with the below specs it works. On a second machine with the below specs the error is thrown.

Internet Explorer 11
Security settings at Medium-Low
Windows 7 64 Bit SP 1
Windows Updates set to automatic.

I posted on a JavaScript forum. Hopefully someone may have some ideas there.

Thanks.
 

Users who are viewing this thread

Top Bottom