Adding, Opening, and Saving Documents
Document objects have the following expected methods for document housekeeping:
- The Add method
The Add method of the Documents collection creates a new Word document and adds it to the Documents collection. The new document becomes the active document. The syntax is:
DocumentsObject.Add(Template, NewTemplate)where
Templateis the name of the template to be used for the new document. If this argument is omitted, the Normal template is used. TheNewTemplateparameter can be set to True to open the document as a template. The default value is False.- The Open method
The Open method of the Documents collection opens an existing document and adds it to the Documents collection. The syntax is a bit involved:
DocumentsObject.Open(FileName, ConfirmConversions, _ ReadOnly, AddToRecentFiles, PasswordDocument, _ PasswordTemplate, Revert, WritePasswordDocument, _ WritePasswordTemplate, Format)
All of these parameters are variants, and all except
FileNameare optional.
The parameters that do not relate to password protection are:
- FileName
The name of the document (can include a complete path).
- ConfirmConversions
Set to True to display the Convert File dialog box if the file is not in Microsoft Word format.
- ReadOnly
Set to True to open the document as read-only.
- AddToRecentFiles
Set to True to add the filename to the list of recently used files at the bottom of the File menu.
- Revert
Controls what happens if
FileNameis already open. Set the parameter to True to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access