Open Method
Applies To
Documents collection object, OLEFormat object, RecentFile object, Subdocument object, Version object.
Description
Syntax 1: Opens the specified document and adds it to the Documents collection. Returns a Document object.
Syntax 2: Opens the specified object. When applied to a Subdocument or RecentFile object, Syntax 2 returns a Document object.
Syntax 1
expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
ú PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
ú WritePasswordTemplate, Format)
Syntax 2
expression.Open
expression Syntax 1: Required. An expression that returns a Documents object.
Syntax 2: Required. An expression that returns an OLEFormat, RecentFile, Subdocument, or Version object.
FileName Required Variant. The name of the document (paths are accepted). In Windows, you can specify multiple files by separating the file names with spaces; on the Macintosh, you can specify only one file.
ConfirmConversions Optional Variant. True to display the Convert File dialog box if the file isn't in Word format.
ReadOnly Optional Variant. True to open the document as read-only.
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 Name is the file 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 following WdOpenFormat constants: wdOpenFormatAuto, wdOpenFormatDocument, wdOpenFormatRTF, wdOpenFormatTemplate, wdOpenFormatText, or wdOpenFormatUnicodeText. The default value is wdOpenFormatAuto.
To specify an external file format, apply the OpenFormat property to a FileConverter object to determine the value to use with this argument.
See Also
Close method, ConfirmConversions property, DefaultOpenFormat property, Documents property, OpenAsDocument method, OpenFormat property.
Example
This example opens MyDoc.doc as a read-only document.
Documents.Open FileName:="C:\MyFiles\MyDoc.doc", ReadOnly:=True
This example opens each document in the RecentFiles collection.
For Each rFile In RecentFiles
rFile.Open
Next rFile
This example opens the most recent version of Report.doc.
Set myDoc = Documents("Report.doc")
myDoc.Versions(myDoc.Versions.Count).Open
This example opens Test.wp using the WordPerfect 6.x file converter.
num = FileConverters("WordPerfect6x").OpenFormat
Documents.Open FileName:="C:\Test.wp", Format:=num
This Macintosh example opens the document named Hello.
Documents.Open FileName:="Hard Drive:Files:Hello"