Results 1 to 2 of 2

Thread: Opening web page in a new window [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Posts
    131

    Resolved Opening web page in a new window [RESOLVED]

    I have the code to open a web page when a button is clicked, but it just changes the current IE window. How do I modify this code to open the page in a new window?

    VB Code:
    1. Option Explicit
    2. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    3. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    4.  
    5. Private Const SW_SHOWNORMAL As Long = 1
    6. Private Const SW_SHOWMINIMIZED As Long = 2
    7. Private Const SW_SHOWMAXIMIZED As Long = 3

    and the button code:
    VB Code:
    1. Private Sub cmdCRKC_Click()
    2. ShellExecute Me.hwnd, "Open", "http://localhost/indexCRKCG1_G2.asp", vbNullString, "C:\", SW_SHOWNORMAL
    3. End Sub
    Last edited by espylacopa; Mar 9th, 2005 at 01:51 PM.
    Things fall apart which the center cannot hold...

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Opening web page in a new window

    Courtesy of TheVader. This will open 4 different pages in 4 different windows. Set a reference to Microsoft Internet Explorer Controls
    VB Code:
    1. Option Explicit
    2.  
    3. Private objIE As InternetExplorer
    4.  
    5. Private Sub Command1_Click()
    6.  
    7. Set objIE = New InternetExplorer
    8.  
    9. objIE.Visible = True
    10. objIE.Navigate2 "http://www.vbforums.com"
    11.  
    12. Do While objIE.Busy = True
    13.     DoEvents
    14. Loop
    15.  
    16. Set objIE = Nothing
    17. End Sub
    18.  
    19. Private Sub Command2_Click()
    20. Set objIE = New InternetExplorer
    21.  
    22. objIE.Visible = True
    23. objIE.Navigate2 "http://www.google.com"
    24.  
    25. Do While objIE.Busy = True
    26.     DoEvents
    27. Loop
    28.  
    29. Set objIE = Nothing
    30. End Sub
    31.  
    32. Private Sub Command3_Click()
    33. Set objIE = New InternetExplorer
    34.  
    35. objIE.Visible = True
    36. objIE.Navigate2 "http://www.microsoft.com"
    37.  
    38. Do While objIE.Busy = True
    39.     DoEvents
    40. Loop
    41.  
    42. Set objIE = Nothing
    43. End Sub
    44.  
    45. Private Sub Command4_Click()
    46. Set objIE = New InternetExplorer
    47.  
    48. objIE.Visible = True
    49. objIE.Navigate2 "http://www.hotmail.com"
    50.  
    51. Do While objIE.Busy = True
    52.     DoEvents
    53. Loop
    54.  
    55. Set objIE = Nothing
    56. End Sub

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