Export (0) Print
Expand All

DocumentExtensions.GetVstoObject Method (_Document, Factory)

Returns a Microsoft.Office.Tools.Word.Document host item that extends the functionality of the current Microsoft.Office.Interop.Word.Document object in a document-level customization. Pass the Globals.Factory object in your project to the factory parameter.

Namespace:  Microsoft.Office.Tools.Word.Extensions
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public static Document GetVstoObject(
	this _Document document,
	Factory factory
)

Parameters

document
Type: Microsoft.Office.Interop.Word._Document

The native document object to extend. Do not supply this parameter yourself. When you call this method on a Word document, the runtime supplies this parameter.

factory
Type: Microsoft.Office.Tools.Word.Factory

An object that provides access to certain features in your document-level customization. Pass the Globals.Factory object to this parameter.

Return Value

Type: Microsoft.Office.Tools.Word.Document
A host item that extends the functionality of the current Microsoft.Office.Interop.Word.Document object.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type _Document. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

In a document-level customization, you can call this method to get a Microsoft.Office.Tools.Word.Document host item that is in the current customization. If the Microsoft.Office.Interop.Word.Document object on which you call this method is not the underlying object of a Microsoft.Office.Tools.Word.Document host item in the current customization, this method returns null.

This method is provided for backward compatibility with Office projects that you retarget from the .NET Framework 3.5 to the .NET Framework 4 or the .NET Framework 4.5. In new projects that target the .NET Framework 4 or the .NET Framework 4.5, you should call the GetVstoObject method that is provided by the Globals.Factory object in your project. For more information, see Programming Document-Level Customizations.

NoteNote

The document parameter is of type Microsoft.Office.Interop.Word._Document, which is the parent interface of Microsoft.Office.Interop.Word.Document. Therefore, this method extends both types: Microsoft.Office.Interop.Word._Document and Microsoft.Office.Interop.Word.Document. Typically, when you reference a Word document, you use a Microsoft.Office.Interop.Word.Document.

Show:
© 2015 Microsoft