How to: Open Existing Documents
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Project type
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
The Open(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) method opens the existing Microsoft Office Word document specified by a fully qualified path and file name. This method returns a Document.
To open a document
Call the Open(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) method of the Documents collection and supply a path to the document.
Me.Application.Documents.Open("C:\Test\NewDocument.doc")
object fileName = @"C:\Test\NewDocument.doc"; this.Application.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
To open a document as read-only
Call the Open(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) method, supply a path to the document, and set the ReadOnly argument to True in the method call.
Me.Application.Documents.Open(FileName:="C:\Test\NewDocument.doc", ReadOnly:=True)
object readOnly = true; object fileName = @"C:\Test\NewDocument.doc"; this.Application.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Compiling the Code
This code example requires the following:
- A document named NewDocument.doc must exist in a directory named Test on drive C.
See Also
Tasks
Concepts
The Variable missing and Optional Parameters in Office Solutions