ComHelper Class
Provides methods for COM clients to load a document into Aspose.Words.
Inheritance Hierarchy

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
public class ComHelper

The ComHelper type exposes the following members.

Public methodCode exampleComHelper
Initializes a new instance of this class.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleOpen(Stream)
Allows a COM application to load Document from a stream.
Public methodCode exampleOpen(String)
Allows a COM application to load a Document from a file.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

Use the ComHelper class to load a document from a file or stream into a Document object in a COM application.

The Document class provides a default constructor to create a new document and also provides overloaded constructors to load a document from a file or stream. If you are using Aspose.Words from a .NET application, you can use all of the Document constructors directly, but if you are using Aspose.Words from a COM application, only the default Document constructor is available.


Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")

Dim doc
Set doc = helper.Open(fileName)
Shows how to open documents using the ComHelper class.

// If you need to open a document within a COM application,
// you will need to do so using the ComHelper class as instead of the Document constructor
ComHelper comHelper = new ComHelper();

// There are two ways of using a ComHelper to open a document
// 1: Using a filename
Document doc = comHelper.Open(MyDir + "Document.docx");
Assert.AreEqual("Hello World!\f", doc.GetText());

// 2: Using a Stream
using (FileStream stream = new FileStream(MyDir + "Document.docx", FileMode.Open))
    doc = comHelper.Open(stream);
    Assert.AreEqual("Hello World!\f", doc.GetText());
See Also