Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Fri, 15 Feb 2008 16:04:50 +0800,    group: microsoft.public.word.vba.beginners        back       


Using VBA to open a new web page   
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!
date: Fri, 15 Feb 2008 16:04:50 +0800   author:   robot

Re: Using VBA to open a new web page   
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
date: Fri, 15 Feb 2008 14:06:25 +0100   author:   Helmut Weber

Re: Using VBA to open a new web page   
Hi Helmut,

Your code works, thank you so much!
date: Mon, 18 Feb 2008 16:30:47 +0800   author:   robot

Re: Using VBA to open a new web page   
robot wrote:
> 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
-- 
.NET: It's About Trust!
 http://vfred.mvps.org
date: Wed, 20 Feb 2008 10:14:02 -0800   author:   Karl E. Peterson

Re: Using VBA to open a new web page   
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.
date: Fri, 7 Mar 2008 17:22:43 +0800   author:   robot

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us