ComHelper

ComHelper class

Provides methods for COM clients to load a document into Aspose.Words.

public class ComHelper

Constructors

NameDescription
ComHelper()Initializes a new instance of this class.

Methods

NameDescription
Open(Stream)Allows a COM application to load Document from a stream.
Open(string)Allows a COM application to load a Document from a file.
OpenIStream(IStream)Allows a COM application to load a Document from an IStream object.

Remarks

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.

Examples

[VBScript]

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

Dim doc
Set doc = helper.Open(fileName)

Shows how to open documents using the ComHelper class.

// The ComHelper class allows us to load documents from within COM clients.
ComHelper comHelper = new ComHelper();

// 1 -  Using a local system filename:
Document doc = comHelper.Open(MyDir + "Document.docx");

Assert.AreEqual("Hello World!\r\rHello Word!\r\r\rHello World!", doc.GetText().Trim());

// 2 -  From a stream:
using (FileStream stream = new FileStream(MyDir + "Document.docx", FileMode.Open))
{
    doc = comHelper.Open(stream);

    Assert.AreEqual("Hello World!\r\rHello Word!\r\r\rHello World!", doc.GetText().Trim());
}

See Also