HTML Links fail to open when Macro is Running

B

Barry

Please Help.

I use Word Macros extensively throughout our office. One of my
coworkers decided to create some HTML pages to access our 100's of
procedures. So what I've done is added a link to my Word Macro
Application Launcher that shells out to ie6 and displays the HTML
pages.

Code to open HTML page follows:

Shell Chr$(34) + "C:\Program Files\Internet Explorer\IEXPLORE.EXE" +
Chr$(34) + _
"I:\I.M.S\MacroFiles\MasterTemplates\IMS Web Pages\Emergency
Procs.htm", vbMaximizedFocus

Now the problem is that when the user clicks on one of the
links,(linked to word documents) the browser returns the infamous "The
page cannot be displayed" error.

The current workaround is to restart the macro program that I
currently use, once it is restarted and the link is accessed once
again, the link opens fine. So I'm wondering why the link won't open
on the 1st attempt.

Any help would be greatly appreciated.

Windows 2000
Word XP
IE 6.0.2800
 
J

Jonathan West

Hi barry,

You'll need quotes around the pathname of the html file being opened,
because there are spaces in the pathname. Also you'll need a space between
the patname of IE and the pathname of the HTML file.

Check it out by doing a debug.print of the string you have created.
 
B

Barry

Thanks for the reply Jonathan,

I still have the same problem, a debug.print of the code

Shell Chr$(34) + "C:\Program Files\Internet Explorer\IEXPLORE.EXE" +
Chr$(34) +
"\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS Web
Pages\home.htm", vbMaximizedFocus

Debug.print equals:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE
"\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS Web
Pages\home.htm 3

which should work fine right ? However it doesn't work on the 1st
attempt, when I close down the macro program and restart, everything
works fine.

There are spaces in the filename but the Chr$(34) should take care of
that.

Thanks for any further help.

Barry
 
J

Jonathan West

Barry said:
Thanks for the reply Jonathan,

I still have the same problem, a debug.print of the code

Shell Chr$(34) + "C:\Program Files\Internet Explorer\IEXPLORE.EXE" +
Chr$(34) +
"\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS Web
Pages\home.htm", vbMaximizedFocus

Debug.print equals:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE
"\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS Web
Pages\home.htm 3

which should work fine right ?

No, you need a pair of quotes round the pathname for IE (you only have the
opening quote mark), then a space, then another pair of quotes round the web
page (again, you only have the opening quote mark), then a comma, then the
number. You are missing the closing quotes and the comma.
 
B

Barry

Jonathan West said:
No, you need a pair of quotes round the pathname for IE (you only have the
opening quote mark), then a space, then another pair of quotes round the web
page (again, you only have the opening quote mark), then a comma, then the
number. You are missing the closing quotes and the comma.

If you look at the code below, there is quotes around the pathname and
the web page but when I do a debug.print, they disappear.

Shell Chr$(34) + "C:\Program Files\Internet Explorer\IEXPLORE.EXE" +
Chr$(34) + "\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS
Web
Pages\home.htm", vbMaximizedFocus
 
J

Jonathan West

Barry said:
"Jonathan West" <[email protected]> wrote in message

If you look at the code below, there is quotes around the pathname and
the web page but when I do a debug.print, they disappear.

Shell Chr$(34) + "C:\Program Files\Internet Explorer\IEXPLORE.EXE" +
Chr$(34) + "\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS
Web
Pages\home.htm", vbMaximizedFocus

If they "disappear" is is because you don't have enough of them. Try this

Shell Chr$(34) & "C:\Program Files\Internet Explorer\IEXPLORE.EXE" _
& Chr$(34) & " " & Chr$(34) & _
"\\satops_01\mainscc\I.M.S\MacroFiles\MasterTemplates\IMS Web
Pages\home.htm" _
& Chr$(34) & ", " & vbMaximizedFocus
 
T

Tom Winter

Forgive me for butting in, but why don't you try this:

Private Declare Function ShellExecuteA Lib "shell32.dll" (ByVal hWnd As
Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long)
As Long

ShellExecuteA 0&, vbNullString, "http://www.amosfivesix.com", vbNullString,
vbNullString, vbNormalFocus

This works in VB6, sorry I haven't tried it in VBA. This has the advantage
(hopefully for you) that it will open the web page in whatever is the user's
default browser. Remember, IE may be installed somwhere else. On old Win95
systems, I've seen it in C:\Program Files\Plus!\...

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top