Discussion Locked

Macro and URLs

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can I open an Internet Explorer URL using a macro with Word?
It doesn't work when I record a macro using:
1. Alt + G (opens Go dialog box)
2. Press Enter key to Open entry box.
3. Type in URL (http://www.google.com)
4. It goes to Google site.
5. I return to word by clicking the taskbar
6. I stop the macro.

But when I try to Run the macro. It will not go to the web site?
Help?

6 replies

by charles byrne

Sure you can:
1. Find Word Document you want macro to run
in by selecting Alt + F8.
2. Edit the Macro you just recorded.
3. Delete all of the code you just created,
except between Sub YourMacro() and
End Sub

4. Insert this Code in between Sub Your Macro
and End Sub. Make sure it is on 1 line:

ActiveDocument.FollowHyperlink Address:="http://www.google.com", NewWindow:=True

5. Close and return to Word and run macro.

Hope this helps,
Charles

by charles byrne

ERRATA:

Sorry, I typed too fast.

3. Should read:

Delete all of the code you just created between Sub YourMacro() and End Sub

procedure should look like this on one
line between Sub Your Macro() and End Sub
or use line continuation character:

Sub YourMacro()
ActiveDocument.FollowHyperlink Address:="http://www.google.com", NewWindow:=True
End Sub

Charles

by gparreira

Hi,rddeane,

Using the web toolbox and inserting the URL there I got the following code:

Sub Macro2()

ActiveDocument.FollowHyperlink Address:="http://www.google.com", NewWindow _
:=False, AddHistory:=True
Application.WindowState = wdWindowStateNormal
End Sub

I think you can use this in your case.

Good luck,
Gilberto

This discussion is closed to new replies.