SaveAs Method
Applies To
Binder object, Section object.
Description
Saves changes to the specified binder or section to a different file. Use this method only for visible binders, or for newly created binders that haven't yet been saved. Returns True if the binder is saved or False if an error occurs and the binder cannot be saved.
Syntax 1
expression.SaveAs(FileName, SaveOption)
expression.SaveAs(FileName)
expression Required. An expression that returns a Binder object (Syntax 1) or a Section object (Syntax 2).
FileName Required for Section, optional for Binder. A string that indicates the name of the file to be saved. You can include a full path; if you don't, the file is saved in the current folder.
SaveOption Optional Variant. Specifies the way the specified binder is saved. Can be one of the following BindSaveOption constants.
Constant | Description |
|
bindFailIfFileExists | If FileName exists, an error occurs (FileName must be specified). This constant is the default value. |
bindOverwriteExisting | If FileName exists, SaveAs overwrites it (FileName must be specified). |
bindDisplayDialog | Displays the Save As dialog box (FileName is optional). If the user closes the Save As dialog box without saving, SaveAs returns False. |
Remarks
The SaveAs method saves sections as unique files without deleting the corresponding sections in the binder. If you want to delete a section from the binder, use the Delete method.
See Also
Save method.
Example
This example determines whether the first section in Binder1.obd is of type Excel.Sheet.8. If it is, the example saves it as the workbook Book1.xls.
Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")
If myBinder.Sections(1).Type = "Excel.Sheet.8" Then
myBinder.Sections(1).SaveAs "MyBook1.xls"
End If
Set myBinder = Nothing
This example creates a new binder, makes it visible, and then prompts the user to save it as Binder1.obd.
Set newBinder = CreateObject("OfficeBinder.Binder")
newBinder.Visible = True
newBinder.SaveAs fileName:="Binder1.obd", _
saveOption:=bindDisplayDialog