Open
Contents
[
Hide
]Open(string)
Allows a COM application to load a Document
from a file.
public Document Open(string fileName)
Parameter | Type | Description |
---|---|---|
fileName | String | Filename of the document to load. |
Return Value
A Document
object that represents a Word document.
Remarks
This method is same as calling the Document
constructor with a file name parameter.
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
- class Document
- class ComHelper
- namespace Aspose.Words
- assembly Aspose.Words
Open(Stream)
Allows a COM application to load Document
from a stream.
public Document Open(Stream stream)
Parameter | Type | Description |
---|---|---|
stream | Stream | A .NET stream object that contains the document to load. |
Return Value
A Document
object that represents a Word document.
Remarks
This method is same as calling the Document
constructor with a stream parameter.
Examples
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
- class Document
- class ComHelper
- namespace Aspose.Words
- assembly Aspose.Words