-
Problem with IE8 automation
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:
[vba]
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
[/vba]
All help & suggestions are greatly appreciated. Thanks in advance,
-Kenneth
-
Ken,
didn't I see this post on the Xtreme VBA talk forum too? I answered you there if I remember correctly.
-
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
-
I keep thinking that this might work if you change the file address. It is "Borrowed" code without credit (my apologies). HTH. Dave
[VBA]
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", 0, 0, 1)
End Sub
[/VBA]
-
This will use the default associated program for .html files to open that file.
[VBA]Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
myShell.Run "D:\LocalFile.html"[/vba]
-
thanks to you for inviting me to your party.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules