?
Solved

VBA for Microsoft Word:  Opening a URL

Posted on 2006-11-16
3
Medium Priority
?
613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 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