PDA

View Full Version : Problem with IE8 automation



klee540
12-05-2009, 08:41 AM
I have an Office 2007 VBA module that uses the MS IE control to open and read from a local html file. This module has worked fine with IE6 & IE7. In IE8, it causes an "Automation Error". It appears the problem has something to do with the opening of a local html file. When I change the code to navigate to an external URL, it runs fine.

Here's the problem module:

Dim ie As InternetExplorer
Dim doc As HTMLDocument
Dim bod As HTMLBody
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "D:\LocalFile.html"
Do Until ie.Busy = False And ie.readyState = 4
DoEvents
Loop
Set doc = ie.Document
ie.Quit
Set ie = Nothing



All help & suggestions are greatly appreciated. Thanks in advance,

-Kenneth

ajetrumpet
12-05-2009, 09:20 PM
Ken,

didn't I see this post on the Xtreme VBA talk forum too? I answered you there if I remember correctly.

klee540
12-07-2009, 02:02 AM
Yes. I just replied u there.

The VBA referencing to the HTML Object library & Internet Controls seem to be correct.

I've tried your suggestion by using the FollowHyperLink method. It works however it doesn't give me the option to hide the browser. I need it to be hidden from the user.

Thanks,
Kenneth

Dave
12-09-2009, 03:26 PM
I keep thinking that this might work if you change the file address. It is "Borrowed" code without credit (my apologies). HTH. Dave

Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Private Sub OpenIE()
Dim r As Long
r = ShellExecute(0, "open", "http://www.vbax.com (http://www.vbax.com/)", 0, 0, 1)
End Sub

JP2112
12-09-2009, 05:50 PM
This will use the default associated program for .html files to open that file.

Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
myShell.Run "D:\LocalFile.html"

jingjing
06-06-2010, 06:52 PM
thanks to you for inviting me to your party.