Visual Basic Concepts
Having one ActiveX document in a project is equivalent to having a single form in a project — somewhat limiting. To increase your capabilities, add a second ActiveX document to the ActXDoc project.
Unlike standard Visual Basic forms, you cannot use the Show method to show ActiveX documents. This is because the container application (in this case, Internet Explorer) determines when to show or hide the ActiveX document. Instead, you must navigate from one ActiveX document to another. To navigate between the two ActiveX documents, use the HyperLink object and its NavigateTo method.
Note This topic is part of a series that walks you through creating a sample ActiveX document. It begins with the topic Creating an ActiveX Document.
To add a second ActiveX document to the ActXDoc project
Command1 property | Value |
Name | cmdGoNext |
Caption | Go Next |
Private Sub cmdGoNext_Click()
' Note: the following path may not correspond to
' the actual path to the SecndDoc.vbd file on
' your machine.
HyperLink.NavigateTo _
App.Path & "\SecndDoc.vbd"
End Sub
Note The App.Path code only works if you keep ActXDoc project in the same directory where you installed the Visual Basic application. If you save the project to another directory, replace App.Path & "\SecndDoc.vbd"
with the hard-coded path of the SecndDoc.vbd file.
When you are running the project, Visual Basic always creates a temporary .vbd file for each ActiveX document in your project, and the .vbd files will always be found in the same directory where Visual Basic has been installed. However, if you are compiling an .exe or .dll, Visual Basic will create the .vbd file in the same directory as the .exe or .dll file.
Label1 property | Value |
Name | lblCaption |
Caption | SecndDoc |
Command1 property | Value |
Name | cmdGoBack |
Caption | Go Back |
Private Sub cmdGoBack_Click()
UserDocument.HyperLink.GoBack
End Sub
The HyperLink object features the GoBack method, which will navigate back to the previous document in the browser.
File | File name | Extension |
User document | SecndDoc | .dob |
Now that you have added a second ActiveX document, you can run the project and navigate between the two.
Tip If you previously opened the FirstDoc ActiveX document in Internet Explorer, click the arrow next to the Address box to see a list of recent URLs. The FirstDoc document should be available from the drop-down list.
This topic is part of a series that walks you through creating a sample ActiveX document.
To | See |
Go to the next step | Adding a Form to the ActXDoc Project |
Start from the beginning | Creating an ActiveX Document |