Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Using VBA to open a new web page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robot - 15 Feb 2008 08:04 GMT
Hello,

I use the following code in Word VBA for firing up the default browser and
opening the Google web site:

Dim objshell As Object
Set objshell = CreateObject("Shell.Application")
objshell.Open "http://www.google.com"

However, if the default browser is already running, the above VBA code will
open the Google web page by *replacing* the "last active web page" (i.e. the
web page that I last visited). How should I modify the code so that the
Google web page will open in a new web page instead?

Suggestions are most welcome!
Helmut Weber - 15 Feb 2008 13:06 GMT
Hi Robot,

maybe:

Sub Test2()
' Dim var
Dim s As String
s = "C:\Program Files\Internet Explorer\iexplore.exe"
s = Chr(34) & s & Chr(34)
s = s & "http://www.google.com"
Shell s
' or
' var = Shell(s)
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
robot - 18 Feb 2008 08:30 GMT
Hi Helmut,

Your code works, thank you so much!
Karl E. Peterson - 20 Feb 2008 18:14 GMT
> Hi Helmut,
>
> Your code works, thank you so much!

No, don't use that!  It's highly fragile, and of course won't be at all to the
user's pleasure if they use Firefox or Opera or something else as the default
browser.  Here's the simple way to load a page in whatever browser the user prefers:
http://vb.mvps.org/samples/HyperJmp
Signature

.NET: It's About Trust!
http://vfred.mvps.org

robot - 07 Mar 2008 09:22 GMT
Karl,

Thank you so much for your help. Even though I use the Shell function
without a problem, I can see that your code is more advanced and more
flexible, so I tried it out and find it to work very well . Thanks again.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.