|
-
Jul 13th, 2000, 07:23 AM
#1
Thread Starter
Member
Open WebPage
how to open a web page, in a new browser ??
i tried:
dim ret as string
ret = Shell("rundll32.exe url.dll,FileProtocolHandler " _
& "http://www.yahoo.com")
but if there is a browser already running, it uses it to open the url instead of opening the url in a new broser.
-
Jul 13th, 2000, 11:21 AM
#2
Code:
Private 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 RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Public Sub ShellNewBrowser(ByVal URL As String, Optional ByVal ShowWindowState As VbAppWinStyle = vbNormalFocus)
Dim lRegKey As Long
Dim sBrowser As String
Dim sData As String * 255
Dim lData As Long
If RegOpenKey(HKEY_CLASSES_ROOT, "htmlfile\shell\open\command", lRegKey) = 0 Then
lData = 255
Call RegQueryValueEx(lRegKey, "", 0&, 0&, ByVal sData, lData)
sBrowser = Left(sData, lData - 1)
Call RegCloseKey(lRegKey)
End If
Shell sBrowser & URL, ShowWindowState
End Sub
Usage:
ShellNewBrowser "http://www.yahoo.com", vbNormalFocus
-
Jul 14th, 2000, 05:47 PM
#3
Thread Starter
Member
dear matthew gates
i tried to run what u wrote and it didnt work, can u fix it?
-
Jul 14th, 2000, 05:51 PM
#4
Try this. Make a Form with a CommandButton and put the following code into it.
Code:
Private 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 Sub Command1_Click()
'Open www.vb-world.net
Retval = ShellExecute(0&, vbNullString, "www.vb-world.net", vbNullString, "C:\", 1)
End Sub
-
Jul 14th, 2000, 07:01 PM
#5
Oh...you just wanted to open a url in a webbrowser? Not open a new window everytime? Sorry bout that..misunderstood.
-
Jul 15th, 2000, 02:27 AM
#6
Thread Starter
Member
to matthew gates
i did want in a n e w webbrowser
the problem is that i tried what you worte to me at first and it didnt work at all, so can u check it again?
-
Jul 15th, 2000, 02:34 AM
#7
Thread Starter
Member
to matthew gates
it gives me error 53, file not found
-
Jul 15th, 2000, 03:37 AM
#8
Fanatic Member
I could swear i already answered to this post...but here goes again...
Code:
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.Navigate(Text1.Text)
it will open a new browser with the url taken from text1.text.
Hope that's what you were looking for,
D!m
-
Jul 15th, 2000, 03:45 AM
#9
Thread Starter
Member
to dim:
it doesnt work with netscape
-
Jul 15th, 2000, 09:27 AM
#10
And there's your answer brucelee. Perhaps it doesn't detect IE?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|