Coding Basics
The Basics of coding an ActiveX Document are the same as any VB Application,
with the exception a few differences. First off, you have the added use of Hyperlink.
A list of events not present in the UserDocument are:
Activate, Deactivate, LinkClose, LinkError,
LinkExecute, LinkOpen, Load, QueryUnload, and Unload events.
You can get a full list of events that are not
available to the UserDocument, and ones which are exclusive to it
from the VB help under the topic UserDocuments.
Coding a UserDocument does require some special
care, as you have to remember that people set their screen to
different settings. While in VB you can fix this by altering the
Width and Height of the form, you can't change the Width and
Height of the UserDocument at runtime. So you might need to take
into account how your document will look at different screen
resolutions. Normally there is no problem going up, but if you
designed at 1024x768, it may look distorted at 640x480. So
designing your controls at 800x600 is a good idea.
The most significant difference when coding your
Document is that if you must reference your paths in Internet
form (which I believe is UNIX form). So / is used as a path
separator not . For an example, if your document is located at
members.aol.com/name/ and you want to open a file in
members.aol.com/name/files you would Hyperlink like...
UserDocument.Hyperlink.NavigateTo
"filesfile.htm"
...taking into account that members.aol.com/name
is assumed as part of the path, since the control is located
there. (same as app.path in VB). Other than that, coding the
UserDocument can be rather fun, and the more features you put
into your document, the better you can make your site. Below is
sample code of each of the Hyperlink property's methods. They are
the main reason UserDocuments work so well. Remember you must do
error checking for the GoForward and GoBack methods, as the
browser won't do it for you:
'Example of GoForward
On Error GoTo NoDocument
UserDocument.Hyperlink.GoForward
Exit Sub
NoDocument:
Resume Next
'Example of GoBack
On Error GoTo NoDocument
UserDocument.Hyperlink.GoForward
Exit Sub
NoDocument:
Resume Next
'Example of NavigateTo
UserDocument.Hyperlink.NavigateTo "http://www.Microsoft.com",,"New_Frame"
The hardest part of all this is remembering to do
the error checking for the two methods. If you don't, your
Document can come to a crashing halt.