Hyperlink.AddToFavorites method (Visio)

Adds a shortcut for a hyperlink address in the presently registered Favorites folder.

Syntax

expression.AddToFavorites( _FavoritesTitle_ )

expression A variable that represents a Hyperlink object.

Parameters

Name Required/Optional Data type Description
FavoritesTitle Optional Variant The title to assign to the new shortcut.

Return value

Nothing

Remarks

If a string is not supplied, the AddToFavorites method uses the hyperlink's Description property as the new favorite's title. If the Description property is empty, the shortcut is given a generic title, such as Favorite1.

The optional favoritesTitle argument can specify the full path for the favorites file, for example, "C:\Users\ username \Favorites\My Favorite.URL", or a path relative to the Favorites folder.

From Microsoft Visual Basic or Microsoft Visual Basic for Applications (VBA), a call to the AddToFavorites method can take either of these two forms:

object.AddToFavorites "SomeString " 
object.AddToFavorites 

From C/C++, if a string is supplied, pass a Variant of type VT_BSTR. The application assigns the string as the title of the shortcut. If a string is not supplied, pass a Variant of type VT_EMPTY, or of type VT_ERROR and HRESULT DISP_E_PARAMNOTFOUND.

Example

The following macro shows how to add a hyperlink to a shape and assign a description and address to the hyperlink. Then it shows four ways to use the AddToFavorites method to add the hyperlink to the Favorites folder.

Before running this macro, replace address with a valid Internet or intranet address, and replace path with a valid path and folder name, including the drive letter, if necessary, on your computer.

Sub AddToFavorites_Example() 
 
 Dim vsoShape As Visio.Shape 
 Dim vsoHyperlink As Visio.Hyperlink 
 
 'Create a new shape to add the hyperlink to. 
 Set vsoShape = ActivePage.DrawRectangle(1, 2, 2, 1) 
 Set vsoHyperlink = vsoShape.AddHyperlink 
 
 'Assign a description and an address to the hyperlink. 
 vsoHyperlink.Description = "Web site" 
 vsoHyperlink.Address = "https://address " 
 
 'Use the default name for the new favorite link. 
 vsoHyperlink.AddToFavorites 
 
 'Specify a different name for the new favorite link. 
 'You don't need to specify the URL extension. 
 vsoHyperlink.AddToFavorites "New Favorite Name" 
 
 'Specify a different path to the favorite. 
 vsoHyperlink.AddToFavorites "path\favoriteName " 
 
 'Set a hyperlink base to allow relative hyperlinks. 
 ThisDocument.HyperlinkBase = "path " 
 
 'Specify a relative path to the Favorites folder. 
 'The URL extension is added automatically. 
 vsoHyperlink.AddToFavorites ".\favoriteName " 
 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.