Share via


Documents.OpenNoRepairDialog Method (Word)

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

Version Information

Version Added: Word 2007

Syntax

expression .OpenNoRepairDialog(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible, OpenAndRepair, DocumentDirection, NoEncodingDialog, XMLTransform)

expression A variable that represents a Documents object.

Parameters

Name

Required/Optional

Data Type

Description

FileName

Required

Variant

The name of the document (paths are accepted).

ConfirmConversions

Optional

Variant

True to display the Convert File dialog box if the file is not in Microsoft Word format.

ReadOnly

Optional

Variant

True to open the document as read-only. This argument does not 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

Variant

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

PasswordDocument

Optional

Variant

The password for opening the document.

PasswordTemplate

Optional

Variant

The password for opening the template.

Revert

Optional

Variant

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

Variant

The password for saving changes to the document.

WritePasswordTemplate

Optional

Variant

The password for saving changes to the template.

Format

Optional

Variant

The file converter to be used to open the document. Can be one of the WdOpenFormat constants. The default is wdOpenFormatAuto.

Encoding

Optional

Variant

The document encoding (code page or character set) to be used by Word when you view the saved document. Can be any valid MsoEncoding constant. For the list of valid MsoEncoding constants, see the Object Browser in the Visual Basic Editor. The default is the system code page.

Visible

Optional

Variant

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

OpenAndRepair

Optional

Variant

True to repair the document to prevent document corruption.

DocumentDirection

Optional

Variant

Indicates the horizontal flow of text in a document. Can be any valid WdDocumentDirection constant. The default is wdLeftToRight.

NoEncodingDialog

Optional

Variant

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

XMLTransform

Optional

Variant

Specifies a transform to use.

Return Value

A Document object that represents the specified document.

Security

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. For recommended best practices on how to do this, see Security Notes for Microsoft Office Solution Developers.

Example

The following example opens MyDoc.doc as a read-only document.

Sub OpenDoc() 
 Documents.OpenNoRepairDialog FileName:="C:\MyFiles\MyDoc.doc", ReadOnly:=True 
End Sub

The following example opens Test.wp by using the WordPerfect 6.x file converter.

Sub OpenDoc2() 
 Dim fmt As Variant 
 fmt = Application.FileConverters("WordPerfect6x").OpenFormat 
 Documents.OpenNoRepairDialog FileName:="C:\MyFiles\Test.wp", Format:=fmt 
End Sub

See Also

Concepts

Documents Object Members

Documents Collection Object