Documents.Open(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) Documents.Open(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) Method

Definition

Opens the specified document and adds it to the Documents collection.

public Microsoft.Office.Interop.Word.Document Open (ref object FileName, ref object ConfirmConversions, ref object ReadOnly, ref object AddToRecentFiles, ref object PasswordDocument, ref object PasswordTemplate, ref object Revert, ref object WritePasswordDocument, ref object WritePasswordTemplate, ref object Format, ref object Encoding, ref object Visible, ref object OpenAndRepair, ref object DocumentDirection, ref object NoEncodingDialog, ref object XMLTransform);
Public Function Open (ByRef FileName As Object, Optional ByRef ConfirmConversions As Object, Optional ByRef ReadOnly As Object, Optional ByRef AddToRecentFiles As Object, Optional ByRef PasswordDocument As Object, Optional ByRef PasswordTemplate As Object, Optional ByRef Revert As Object, Optional ByRef WritePasswordDocument As Object, Optional ByRef WritePasswordTemplate As Object, Optional ByRef Format As Object, Optional ByRef Encoding As Object, Optional ByRef Visible As Object, Optional ByRef OpenAndRepair As Object, Optional ByRef DocumentDirection As Object, Optional ByRef NoEncodingDialog As Object, Optional ByRef XMLTransform As Object) As Document

Parameters

FileName

Required Object. The name of the document (paths are accepted).

ConfirmConversions

Optional Object. True to display the Convert File dialog box if the file isn't in Microsoft Word format.

ReadOnly

Optional Object. True to open the document as read-only.Note This argument doesn't override the read-only recommended setting on a saved document. For example, if a document has been saved with read-only recommended turned on, setting the ReadOnly argument to False will not cause the file to be opened as read/write.

AddToRecentFiles

Optional Object. True to add the file name to the list of recently used files at the bottom of the File menu.

PasswordDocument

Optional Object. The password for opening the document.

PasswordTemplate

Optional Object. The password for opening the template.

Revert

Optional Object. Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.

WritePasswordDocument

Optional Object. The password for saving changes to the document.

WritePasswordTemplate

Optional Object. The password for saving changes to the template.

Format

Optional Object. The file converter to be used to open the document. Can be a WdOpenFormat constant.To specify an external file format, apply the OpenFormat property to a FileConverter object to determine the value to use with this argument.

Encoding

Optional Object. The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document. Can be any valid MsoEncoding constant. The default value is the system code page.

Visible

Optional Object. True if the document is opened in a visible window. The default value is True.

OpenAndRepair

Optional Object. True to repair the document to prevent document corruption.

DocumentDirection

Optional Object. Can be a WdDocumentDirection constant.

NoEncodingDialog

Optional Object. True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.

XMLTransform

Optional Object. Specifies a transform to use.

Returns

Remarks

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

Applies to