FileOpen

Syntax

FileOpen .Name = text [, .ConfirmConversions = number] [, .ReadOnly = number] [, .AddToMru = number] [, .PasswordDoc = text] [, .PasswordDot = text] [, .Revert = number] [, .WritePasswordDoc = text] [, .WritePasswordDot = text]

Remarks

Opens the specified document. If the document does not exist, or is not located in the specified folder, an error occurs. Most arguments for the FileOpen statement correspond to the options in the Open dialog box (File menu).

Argument

Explanation

.Name

The name of the document (paths are accepted). In Windows, you can specify multiple files by separating the filenames with spaces; on the Macintosh and in Windows NT, you can specify only one file per FileOpen instruction.

If you use Dialog or Dialog() to display the Open dialog box, you can display files of a certain type by setting .Name to a file specification. To display text files, for example, the file specification would be "*.TXT" (Windows) or MacID$("TEXT") (Macintosh). For an example, see MacID$().


Argument

Explanation

.ConfirmConversions

If 1, displays the Convert File dialog box if the file is not in Word format.

.ReadOnly

If 1, opens the document as read-only.

.AddToMru

If 1, adds the filename to the list of recently used files at the bottom of the File menu. (Note that MRU is an abbreviation for "most recently used.")

.PasswordDoc

The password to open the document, if required.

.PasswordDot

The password to open the template, if required.

.Revert

Controls what happens if .Name is the filename of an open document:

0 (zero) Word activates the open document.

1 Word discards any unsaved changes to the open document and reopens the file.

.WritePasswordDoc

The password to save changes to the document, if required.

.WritePasswordDot

The password to save changes to the template, if required.


In Windows 95 and Windows NT, if any part of the path or filename for a file specified by .Name contains a space character, the entire path and filename must be enclosed by Chr$(34) characters, as shown in the following example:


FileOpen .Name = Chr$(34) + "C:\DOCUMENTS\AUGUST REPORT" + Chr$(34)

You can specify multiple files using this technique as well. Each filename must be separated by a space character, as shown in the following example:


FileOpen .Name = Chr$(34) + "JUNE REPORT" + Chr$(34) + " " + \
        Chr$(34) + "JULY REPORT" + Chr$(34) + " " + \
        Chr$(34) + "AUGUST REPORT" + Chr$(34)

On the Macintosh, paths and filenames that contain spaces should not be enclosed by Chr$(34) characters. The following Macintosh example shows the correct way to specify a path and filename with spaces in them in a Macintosh FileOpen instruction:


FileOpen .Name = "HD:MONTHLY REPORTS:AUGUST REPORT"

Examples

This Windows example changes the current folder, and then opens a read-only copy of MYDOC.DOC:


ChDir "C:\WINWORD\DOCS"
FileOpen .Name = "MYDOC.DOC", .ReadOnly = 1

The following Macintosh example also opens MY DOCUMENT, but because the full path is specified, no ChDir instruction is required before the FileOpen instruction:


FileOpen .Name = "HD:WORD:MY DOCUMENT", .ReadOnly = 1

See Also

FileConfirmConversions, FileFind, FileNew, MacID$()