ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please Help - Trying to Launch IE from Excel (https://www.excelbanter.com/excel-programming/406627-please-help-trying-launch-ie-excel.html)

eBob.com[_2_]

Please Help - Trying to Launch IE from Excel
 
I am trying to launch IE from a VBA macro in Excel. After a great deal of
web searching I came up with the following ...

Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (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

<some other stuff

Sub test23()
Dim WEB_SITE_URL As String
WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1

'Launch Web Site
ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

When I execute test23 I get a windows explorer window opening up to the My
Documents directory. No error messages.

I think that I am close. Could someone please help me get this to launch IE.

Thanks, Bob




Helmut Weber

Please Help - Trying to Launch IE from Excel
 
Hi "Bob",

in the word groups I answered that question, like that:

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

Yet Karl E. Peterson, who is quite an authority, told me:

"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"

Make the best of all of it.


Merle

Please Help - Trying to Launch IE from Excel
 
You could just insert a hyperlink.

"eBob.com" wrote:

I am trying to launch IE from a VBA macro in Excel. After a great deal of
web searching I came up with the following ...

Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (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

<some other stuff

Sub test23()
Dim WEB_SITE_URL As String
WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1

'Launch Web Site
ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

When I execute test23 I get a windows explorer window opening up to the My
Documents directory. No error messages.

I think that I am close. Could someone please help me get this to launch IE.

Thanks, Bob





michael.beckinsale

Please Help - Trying to Launch IE from Excel
 
Hi eBob,

Heres some pretty simple code l have been using for along time, and
gives you control over the size of the IE window etc.(they are of
course optional)

Hope it helps

Sub MyIE()

Set IE = CreateObject("InternetExplorer.Application")
IE.AddressBar = False
IE.MenuBar = False
IE.Toolbar = False
IE.Width = 600
IE.Height = 750
IE.Left = 0
IE.Top = 0
IE.navigate "www.yahoo.com"
IE.resizable = True
IE.Visible = True

End Sub

Regards

Michael

Tim Williams

Please Help - Trying to Launch IE from Excel
 
activeworkbook.followhyperlink "http://www.google.com"

Tim


"eBob.com" wrote in message
...
I am trying to launch IE from a VBA macro in Excel. After a great deal of
web searching I came up with the following ...

Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (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

<some other stuff

Sub test23()
Dim WEB_SITE_URL As String
WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1

'Launch Web Site
ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

When I execute test23 I get a windows explorer window opening up to the My
Documents directory. No error messages.

I think that I am close. Could someone please help me get this to launch
IE.

Thanks, Bob






eBob.com[_2_]

Please Help - Trying to Launch IE from Excel
 
Yes, and that has an advantage if I ever want to export the spreadsheet to
an html file. But it also makes the spreadsheet unnecessarily large. So I
prefer the macro solution.

Bob

"Merle" wrote in message
...
You could just insert a hyperlink.

"eBob.com" wrote:

I am trying to launch IE from a VBA macro in Excel. After a great deal
of
web searching I came up with the following ...

Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (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

<some other stuff

Sub test23()
Dim WEB_SITE_URL As String
WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1

'Launch Web Site
ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

When I execute test23 I get a windows explorer window opening up to the
My
Documents directory. No error messages.

I think that I am close. Could someone please help me get this to launch
IE.

Thanks, Bob







JP[_4_]

Please Help - Trying to Launch IE from Excel
 
How about this?

Option Explicit
Sub GoToWebSite()

Dim appIE As InternetExplorer
Dim sURL As String
Application.ScreenUpdating = False

Set appIE = New InternetExplorer

sURL = "http://www.mywebsite.com"

With appIE
.Navigate sURL
.Visible = True
End With

Application.ScreenUpdating = True

Set appIE = Nothing
End Sub


Of course you would need to set a reference to Microsoft Internet
Controls (shdocvw.dll). For more samples check out
http://www.codeforexcelandoutlook.co...texplorer.html

HTH,
JP


On Feb 26, 11:09*am, "eBob.com" wrote:
Yes, and that has an advantage if I ever want to export the spreadsheet to
an html file. *But it also makes the spreadsheet unnecessarily large. *So I
prefer the macro solution.

Bob

"Merle" wrote in message

...



You could just insert a hyperlink.


"eBob.com" wrote:


I am trying to launch IE from a VBA macro in Excel. *After a great deal
of
web searching I came up with the following ...


Public Declare Function ShellExecute Lib "shell32.dll" _
* * Alias "ShellExecuteA" (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


<some other stuff


Sub test23()
* * * * *Dim WEB_SITE_URL As String
* * * * *WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1


* * 'Launch Web Site
* * ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
* * * * * * * * *vbNullString, SW_SHOWNORMAL
End Sub


When I execute test23 I get a windows explorer window opening up to the
My
Documents directory. *No error messages.


I think that I am close. Could someone please help me get this to launch
IE.


Thanks, *Bob- Hide quoted text -


- Show quoted text -



eBob.com[_2_]

Please Help - Trying to Launch IE from Excel
 
Thanks for the many responses. They were all helpful. This response from
Tim seems like the perfect solution to my problem.

Thanks again to Tim and everyone else who responded.

Bob

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
activeworkbook.followhyperlink "http://www.google.com"

Tim


"eBob.com" wrote in message
...
I am trying to launch IE from a VBA macro in Excel. After a great deal of
web searching I came up with the following ...

Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (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

<some other stuff

Sub test23()
Dim WEB_SITE_URL As String
WEB_WITE_URL = "http://www.mysite.com"
Dim SW_SHOWNORMAL As Integer
SW_SHOWNORMAL = 1

'Launch Web Site
ShellExecute 0, vbNullString, WEB_SITE_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

When I execute test23 I get a windows explorer window opening up to the
My Documents directory. No error messages.

I think that I am close. Could someone please help me get this to launch
IE.

Thanks, Bob









All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com