Muokkaa

Jaa


Document.AddToFavorites method (Word)

Creates a shortcut to the document or hyperlink and adds it to the Favorites folder.

Syntax

expression.AddToFavorites

expression Required. A variable that represents a Document object.

Example

This example creates a shortcut for each hyperlink in the active document and adds it to the Favorites folder.

For Each myHyperlink In ActiveDocument.Hyperlinks 
 myHyperlink.AddToFavorites 
Next myHyperlink

This example creates a shortcut to Sales.doc and adds it to the Favorites folder. If Sales.doc isn't currently open, this example opens it from the C:\Documents folder.

For Each doc in Documents 
 If LCase(doc.Name) = "sales.doc" Then isOpen = True 
Next doc 
If isOpen <> True Then Documents.Open _ 
 FileName:="C:\Documents\Sales.doc" 
Documents("Sales.doc").AddToFavorites

See also

Document Object

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.