Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Word Solutions
 How to: Open Existing Documents
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)
How to: Open Existing Documents

Updated: November 2007

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

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Word 2003

  • Word 2007

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.

    Visual Basic
    Me.Application.Documents.Open("C:\Test\NewDocument.doc")
    
    
    C#
    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.

    Visual Basic
    Me.Application.Documents.Open(FileName:="C:\Test\NewDocument.doc", ReadOnly:=True)
    
    
    C#
    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);
    
    

This code example requires the following:

  • A document named NewDocument.doc must exist in a directory named Test on drive C.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker