Consulting

Results 1 to 6 of 6

Thread: Problem with IE8 automation

  1. #1
    VBAX Newbie
    Joined
    Dec 2009
    Posts
    2
    Location

    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

  2. #2
    Ken,

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

  3. #3
    VBAX Newbie
    Joined
    Dec 2009
    Posts
    2
    Location
    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

  4. #4
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    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]

  5. #5
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    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]
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  6. #6
    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
  •