The code described so far in this chapter is tailored to one type of container
or another. However one of the main features of Active Document development is the fact that
you don't know ahead of time which container might be using your document.
For more discussion of this topic, see the section in this chapter entitled
"Detecting the
Type of Container with the TypeName function and UserDocument.Parent."
You must therefore write code such as that shown in Listing 14.11.
LISTING 14.11
DIFFERENT NAVIGATION CODE FOR DIFFERENT CONTAINER TYPES
'Assume we've
already
'determined document
'name in strTargetDoc
Dim strContainerType as String
strContainerType = Ucase$(TypeName(UserDocument.Parent))
'If container is Internet Explorer:
If Instr(strContainerType, "WEBBROWSER")
<> 0 Then
UserDocument.Hyperlink.NavigateTo
_
"File://" &
strTargetDoc
'or if it's Office Binder:
ElseIf strContainerType = "SECTION"
Then
UserDocument.Parent.Parent.Sections.
_
Add , strTarget
'or if the container type is unknown
Else
MsgBox "Can't
activate document
End If
This code will serve to navigate to the same document from either Office Binder
or Internet Explorer.