Solved

VBA for Microsoft Word:  Opening a URL

Posted on 2006-11-16
3
609 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

733 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