-
All im trying to do is open an Internet Browser and make it go to a specifik URL. Now okay, that i can get working. The problem is, that when i have a browser open - lets say on yahoo.com - and i run the "open browser and goto url" part of my code, it will take my current browser - the one thats on yahoo.com - and go away from yahoo to the URL. The idea is to get the browser to open up a new window with the URL.
This cannot be to heard for someone with a little experience? I have been on the search for a long time now, so i really hope someone can help me out here.
-
This works for me....
Just replace the url with yours...
even if the setting to re-use same window for shortcuts is enabled...this should work.
If it does not...It may be something in one of you IE option settings.
-
That partially works. I mean to say that if the PATH to IE is a little different on some other computer it won't work. Or if the client might be using Netscape. Maybe you could do a workaround, by somehow getting the path for the default browser. But i don't know if thats possible, don't know that much about vb.
Michael J
-
Here ya gowww :)
Code:
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
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
Public Sub Navigate(Url As String)
Dim sEXE As String
sEXE = FindBrowserEXE
If Len(sEXE) Then
ShellExecute hWnd, "OPEN", sEXE, Url, "", 1
End If
End Sub
Function FindBrowserEXE() As String
Dim sPath As String
Dim iFile As Integer
sPath = space(255)
iFile = FreeFile
Open "C:\Temp.htm" For Output As iFile
Close iFile
'this part isn't mine, can't remember where I got it.
FindBrowserEXE = Left(sPath, FindExecutable("C:\Temp.htm", "", ByVal sPath))
Kill "C:\Temp.htm"
End Function
Place it in a module and run
Code:
Navigate "http://www.cool.com"
Hope that helps ;)
-
This might be a dumb question but, how come it has a problem with this line:
ShellExecute hWnd, "OPEN", sEXE, Url, "", 1
It says that the "hWnd" variable is not defined?
Michael J
-
That partially works. I mean to say that if the PATH to IE is a little different on some other computer it won't work. Or if the client might be using Netscape. Maybe you could do a workaround, by somehow getting the path for the default browser. But i don't know if thats possible, don't know that much about vb.
Michael J
-
I'm possibly very wrong here as I'm only learning this, but try ShellExecute.hWnd.
Sorry if I'm wrong :)
-
ah.. nothing big,just put Form1.hWnd
-
The post that >Job< sent worked fine on my computer. However, when I tried it on another computer, it did not work - more specific, it could not find the path of the program associated with the file c:\temp.htm.
A guy in need of help! Michael J