The information in this article applies to:
SUMMARY
This article illustrates how to use the hyperlink object from a
UserDocument (Visual Basic Active Document) to navigate to another
document. It demonstrates the following:
MORE INFORMATION
From your UserDocument, you can jump to other UserDocuments that are in
your application (Internal Jumping) or you can jump to other Web locations
or documents (External Jumping). In both cases, you use the Hyperlink
object's NavigateTo method and supply an absolute URL to where you want to
jump. For example, you can do the following from your UserDocument code:
This will cause Internet Explorer to navigate to the specified location. You can also use this method for jumping to other UserDocuments in your application. Because you have to specify an absolute URL, using this approach for other UserDocuments on a Web site requires extra work. You need to know the full URL from which the document (.vbd) was launched. You can get this information using Parent.LocationURL from your UserDocument code. The location can be either a Web URL or a UNC file location name. NOTE: You should use the Parent.LocationURL property for retrieving the location of the UserDocument. Parent.LocationURL, unlike Parent.LocationName, works identically in both Internet Explorer 3 and Internet Explorer 4. In Internet Explorer 3, LocationName returns the complete path just as LocationURL does. In Internet Explorer 4, LocationName does not always return a complete path. You should not use App.Path because it returns the location where your EXE or DLL exists locally, not the location from where the VBD was downloaded. Constructing an Absolute URLAs mentioned before, you need an absolute URL for Hyperlink.NavigateTo method. This can be tricky for jumping to other UserDocuments in your application because the UserDocuments can reside on a local (or network) file or on a Web server. The following function takes the value returned by Parent.LocationURL, strips off the filename, and returns a path string. You can then append the name of any UserDocument that resides at the same base URL as the current document to the path string, and use the final result to call NavigateTo:
As an example, suppose you have a Doc1.VBD and a Doc2.VBD stored on a server at http://demo/hyperlink, but you do not want to hardcode the server name in your code so that these VBD files can be moved easily from one server location to another. To jump from Doc1.vbd to Doc2.vbd, you can use the above function as follows:
Because PathFromURL can work on both URLs and UNC, this technique will work in both cases without changing code. Also, note that PathFromURL returns the final / or \, so you simply need to append your .vbd file name. Additional query words:
LocationName LocationURL Hyperlink kbInternet kbVBp500 kbVBp600 kbdsi
Keywords : |
Last Reviewed: September 22, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |