Solved

VBA for Microsoft Word:  Opening a URL

Posted on 2006-11-16
3
607 Views
Last Modified: 2008-02-26
Hi - could someone please advise how to open a URL from VBA within Word.

I can re-focus on an open Internet Explorer using AppActivate, but I want to open a fresh instance of Internet Explorer and navigate to a specific URL without any interaction by the user, ie: no hyperlink to click on or button to press etc.

Also, will the code someone lists work with both IE6 and the new IE7 or more specifically, Microsoft Internet Explorer and Windows Internet Explorer.

Many thanks.

Justin.
0
Comment
Question by:justinkent
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 17954700
Greetings, justinkent.

The code below will create a new instance of Internet Explorer, navigate to the URL given, and then make the browser visible.  This works fine in IE6, not sure about IE7 as I don't have it loaded, but I'm pretty confident this'll work.  

Sub OpenIE()
    Const READYSTATE_COMPLETE = 4
    Dim objIE As Object
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate2 "http://www.yahoo.com"
    Do While objIE.readyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    objIE.Visible = True
    Set objIE = Nothing
End Sub

Cheers!
0
 

Author Comment

by:justinkent
ID: 17957094
Perfect, thanks.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17967290
You're welcome.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Vlookup to move data back to source. 4 92
Validating VB6 Function 19 60
VB6 Compile Compatibility Issue 4 102
How to Add / Edit Windows Menu 4 61
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question