Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 14

Writing an Application to Handle Different Containers' Navigation Styles

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.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved