Results 1 to 4 of 4

Thread: [RESOLVED] Opening an URL with VB (again !)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    177

    Resolved [RESOLVED] Opening an URL with VB (again !)

    Hi !

    I use this code in my VB-app, and it works fine on my computer:

    *Dim A as Integer

    A = Shell("C:\Program Files\Internet Explorer\IEXPLORE.exe http://www.xxx.com ", vbMaximizedFocus)*

    But how do I know wether other users have IXPLORER.exe in \Program.. or in \Program Files... ? Is there any codes for covering any situations ?

    /Kalle in Sweden

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Opening an URL with VB (again !)

    try shellexecute api, there will be many examples in this forum
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Opening an URL with VB (again !)

    Start a new VB project and run this code (add a command button Command1 to the form):

    Code:
    Option Explicit
    
    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
    
    'Use API Viewer to see other constants.
    Private Const SW_NORMAL = 1
    
    Private Sub Command1_Click()
        ShellExecute Me.hwnd, "open", _
        "http://www.vbforums.com/newreply.php?do=newreply&noquote=1&p=3190402", _
        vbNullString, vbNullString, SW_NORMAL
    End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    177

    Re: [RESOLVED] Opening an URL with VB (again !)

    Thanks a lot, DigiRev !

    It worked out just fine, and I have not to worry about where IE is located !
    The default browser will be used as I can see...

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