Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Open Existing Documents

NoteNote

Some code examples in this topic use the this or Me keyword or the Globals class in a way that is specific to document-level customizations, or they rely on features of document-level customizations such as host controls. These examples can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination.

The Open method opens the existing Microsoft Office Word 2003 document specified by a fully qualified path and file name. This method returns a Microsoft.Office.Interop.Word.Document.

To open a document

  • Call the Open method of the Documents collection and supply a path to the document.

    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 method, supply a path to the document, and set the ReadOnly argument to True in the method call.

    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 the C: drive.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft