Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Activate IE with URL from Macro (Outlook 2000)

    Aha.... my first Outlook macro project is nearly complete! The missing bit is....

    I need to be able to mimic the clicking of a URL within a mail message. Ie. I'm extracting info from a mail message subject which I can use to construct a URL. With that, I want to activate a running IE (or start one up if it isn't running) and pass it the URL. Is there some nifty bit of code to do this within a macro?

    thanks.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Activate IE with URL from Macro (Outlook 2000)

    I think you have two options:

    (1) Shell the page in the browser. I have used this code:

    strCommand = "" & "crogram filesinternet exploreriexplore.exe " & strFullPathToFile & ""
    dblHandle = Shell(strCommand, vbNormalFocus)

    If you don't need to track the task after popping the window, you can use:

    Shell "crogram filesinternet exploreriexplore.exe http://www.antivirus.com/", vbNormalFocus

    (2) Automate the IE control, shdocvw.dll (I forget which of the IE-related references this is in Tools, References, but if you look for that DLL, you should be able to find the one).

    The second method is the more modern and elegant, but the first should work fine.

  3. #3
    New Lounger
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Activate IE with URL from Macro (Outlook 2000)

    I tried the first solution and it works - thanks very much. Is there some switch or technique to prevent activating a NEW copy of IE every time? I'd like to simply pass the URL to an existing instance, if there's one already running.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Activate IE with URL from Macro (Outlook 2000)

    Well... this doesn't work:

    Dim objIE As SHDocVw.InternetExplorer
    Set objIE = GetObject(, "InternetExplorer.Application")

    So, maybe there is something unusual about IE?

    <furious searching>

    Aha! According to HOWTO: Connect to a Running Instance of Internet Explorer (Q176792), "Normally, an application connects to a running instance of another application using the Running Object table. Because Internet Explorer 4.0 does not register itself in the running object table, another method is necessary."

    If the technique described in that article doesn't help, there is the older trick of sending DDE messages. I'm not sure if Excel has the DDE methods that are built into Word's Application object. If so, see HOWTO: Controlling the Currently Running Instance of IE3 via DDE (Q160976).

    Okay, it's your turn to post some working code. <img src=/S/wink.gif border=0 alt=wink width=15 height=15> Many people will appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •