Results 1 to 5 of 5

Thread: How to Open a new Explorer with URL in ActiveX Control ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    11
    Hello.
    I am writing a ActiveX Control File (VB) which will be packaged as *.CAB
    In this ActiveX Control, I would like to have a button which can open a new Browser with URL.
    How can I do that?

    The simple question is: How can I call a URL with new browser in ActiveX Control (VB) ?

  2. #2
    Guest
    It's easy.

    Add the following code:

    Code:
    Dim ies As New InternetExplorer
    ies.Navigate2 Text1
    And it will open a new IE window and navigats to the url that the text1 specifies.

    Don't forget to add "Microsoft Internet Controls" to your references section.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    That works fine if you assume the end user has and uses Internet Explorer, otherwise you can instantiate the default registered browser using the ShellExecute API, i.e.
    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
    
    Private Sub Command1_Click()
        ShellExecute 0, "OPEN", "http:\\www.vb-world.net", "", "", 1
    End Sub
    If IE is already open this will usually use the Open browser, if you definitely always want to open a new browser window do something like this:
    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
    Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
    
    Private Sub Command1_Click()
        Dim sEXE As String
        sEXE = FindBrowserEXE
        If Len(sEXE) Then
            ShellExecute 0, "OPEN", sEXE, "http:\\www.vb-world.net", "", 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
        
        FindBrowserEXE = Left(sPath, FindExecutable("C:\Temp.htm", "", ByVal sPath))
        Kill "C:\Temp.htm"
    End Function

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    11
    Thank you Escaflowne and Aaron Young.
    But how can I specific the target frame if I want to change the URL in other frame ?

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    11
    Also, one more question.

    In ActiveX Control, can I call Javascript object in the same page?

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