Results 1 to 10 of 10

Thread: Open WebPage

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55

    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.

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55
    dear matthew gates
    i tried to run what u wrote and it didnt work, can u fix it?

  4. #4
    Guest
    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

  5. #5
    Guest
    Oh...you just wanted to open a url in a webbrowser? Not open a new window everytime? Sorry bout that..misunderstood.

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55
    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?

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55
    to matthew gates

    it gives me error 53, file not found

  8. #8
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    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
    Dim

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55
    to dim:
    it doesnt work with netscape

  10. #10
    Guest
    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
  •  



Click Here to Expand Forum to Full Width