Results 1 to 9 of 9

Thread: 2nd time im asking - simple question for vb-programmer

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    6
    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.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Talking This works for me....


    Code:
    Shell "C:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE  http://www.excite.com", vbMaximizedFocus
    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.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    6
    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

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    6
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    6
    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

  7. #7
    Lively Member
    Join Date
    Sep 2000
    Posts
    79
    I'm possibly very wrong here as I'm only learning this, but try ShellExecute.hWnd.


    Sorry if I'm wrong
    The problem with designing something completely foolproof is to underestimate the ingenuity of a complete fool. - Douglas Adams

    I know the human being and fish can coexist peacefully. - GWB

    I think we agree, the past is over. - GWB

  8. #8
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    ah.. nothing big,just put Form1.hWnd
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    6
    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


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