Save related procedures in class Workbook (Excel VBA)

This page presents procedures from class Workbook related to the theme Save: CheckIn, EnableAutoRecover, FileFormat, RemoveDocumentInformation, RemovePersonalInformation, Save and SaveAs

CheckIn

Returns a workbook from a local computer to a server, and sets the local workbook to read-only so that it cannot be edited locally. Calling this method will also close the workbook.

CheckIn (SaveChanges, Comments, MakePublic)

 If Workbooks(strWkbCheckIn).CanCheckIn = True Then 
 Workbooks(strWkbCheckIn).CheckIn 
 MsgBox strWkbCheckIn & " has been checked in." 
 Else 
 MsgBox "This file cannot be checked in " & _ 
 "at this time. Please try again later." 
 End If

Arguments

The following arguments are optional

SaveChanges - True saves changes and checks in the document. False returns the document to a checked-in status without saving revisions

Comments (String) - Allows the user to enter check-in comments for the revision of the workbook being checked in (applies only if SaveChanges equals True).

MakePublic - True allows the user to publish the workbook after it has been checked in. This submits the workbook for the approval process, which can eventually result in a version of the workbook being published to users with read-only rights to the workbook (applies only if SaveChanges equals True)

EnableAutoRecover

Saves changed files of all formats on a timed interval.

If Microsoft Excel fails, the system fails, or if the system is improperly shut down (not allowing Excel to save the changed files), the backed up files are opened and the user has an opportunity to save changes that otherwise would have been lost. When the user restarts Excel, a document recovery window opens, giving the user an option to recover the files they were working on. Setting this property to True (default) enables this feature.

ActiveWorkbook.EnableAutoRecover = True

FileFormat

Returns the file format and/or type of the workbook.

Possible Values are xlAddIn - Microsoft Excel 97-2003 Add-In, xlAddIn8 - Microsoft Excel 97-2003 Add-In, xlCSV - CSV, xlCSVMac - Macintosh CSV, xlCSVMSDOS - MSDOS CSV, xlCSVUTF8 - UTF8 CSV, xlCSVWindows - Windows CSV, xlCurrentPlatformText - Current Platform Text, xlDBF2 - Dbase 2 format, xlDBF3 - Dbase 3 format, xlDBF4 - Dbase 4 format, xlDIF - Data Interchange format, xlExcel12 - Excel Binary Workbook, xlExcel2 - Excel version 2.0 (1987), xlExcel2FarEast - Excel version 2.0 far east (1987), xlExcel3 - Excel version 3.0 (1990), xlExcel4 - Excel version 4.0 (1992), xlExcel4Workbook - Excel version 4.0. Workbook format (1992), xlExcel5 - Excel version 5.0 (1994), xlExcel7 - Excel 95 (version 7.0), xlExcel8 - Excel 97-2003 Workbook, xlExcel9795 - Excel version 95 and 97, xlHtml - HTML format, xlIntlAddIn - International Add-In, xlIntlMacro - International Macro, xlOpenDocumentSpreadsheet - OpenDocument Spreadsheet, xlOpenXMLAddIn - Open XML Add-In, xlOpenXMLStrictWorkbook - Strict Open XML file, xlOpenXMLTemplate - Open XML Template, xlOpenXMLTemplateMacroEnabled - Open XML Template Macro Enabled, xlOpenXMLWorkbook - Open XML Workbook, xlOpenXMLWorkbookMacroEnabled - Open XML Workbook Macro Enabled, xlSYLK - Symbolic Link format, xlTemplate - Excel Template format, xlTemplate8 - Template 8, xlTextMac - Macintosh Text, xlTextMSDOS - MSDOS Text, xlTextPrinter - Printer Text, xlTextWindows - Windows Text, xlUnicodeText - Unicode Text, xlWebArchive - Web Archive, xlWJ2WD1 - Japanese 1-2-3, xlWJ3 - Japanese 1-2-3, xlWJ3FJ3 - Japanese 1-2-3 format, xlWK1 - Lotus 1-2-3 format, xlWK1ALL - Lotus 1-2-3 format, xlWK1FMT - Lotus 1-2-3 format, xlWK3 - Lotus 1-2-3 format, xlWK3FM3 - Lotus 1-2-3 format, xlWK4 - Lotus 1-2-3 format, xlWKS - Lotus 1-2-3 format, xlWorkbookDefault - Workbook default, xlWorkbookNormal - Workbook normal, xlWorks2FarEast - Microsoft Works 2.0 far east format, xlWQ1 - Quattro Pro format, xlXMLSpreadsheet - XML Spreadsheet.

Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

Dim xffFileFormat As XlFileFormat
xffFileFormat = ActiveWorkbook.FileFormat

RemoveDocumentInformation

Removes all information of the specified type from the workbook.

RemoveDocumentInformation (RemoveDocInfoType)

RemoveDocInfoType: Type of information to be removed.

ActiveWorkbook.RemoveDocumentInformation RemoveDocInfoType:=xlRDIAll

RemovePersonalInformation

True if personal information can be removed from the specified workbook. The default value is False.

ActiveWorkbook.RemovePersonalInformation = True

Save

Saves changes to the specified workbook.

To open a workbook file, use the Open method. To mark a workbook as saved without writing it to a disk, set its Saved property to True. The first time you save a workbook, use the SaveAs method to specify a name for the file.

ActiveWorkbook.Save

SaveAs

Saves changes to the workbook in a different file.

Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements.

SaveAs (Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local, WorkIdentity)

ActiveWorkbook.SaveAs

Arguments

The following arguments are optional

Filename (String) - A string that indicates the name of the file to be saved. You can include a full path; if you don't, Microsoft Excel saves the file in the current folder.

FileFormat (XlFileFormat) - The file format to use when you save the file. For a list of valid choices, see the XlFileFormat enumeration. For an existing file, the default format is the last file format specified; for a new file, the default is the format of the version of Excel being used.

Here you can find possible values for XlFileFormat.

Password (String) - A case-sensitive string (no more than 15 characters) that indicates the protection password to be given to the file.

WriteResPassword - A string that indicates the write-reservation password for this file. If a file is saved with the password and the password isn't supplied when the file is opened, the file is opened as read-only

ReadOnlyRecommended (Boolean) - True to display a message when the file is opened, recommending that the file be opened as read-only.

CreateBackup (Boolean) - True to create a backup file.

AccessMode (XlSaveAsAccessMode) - The access mode for the workbook.

Possible Values are xlExclusive - Exclusive mode, xlNoChange - Default (does not change the access mode), xlShared - Share list.

ConflictResolution (XlSaveConflictResolution) - An XlSaveConflictResolution value that determines how the method resolves a conflict while saving the workbook. If set to xlUserResolution, the conflict-resolution dialog box is displayed. If set to xlLocalSessionChanges, the local user's changes are automatically accepted. If set to xlOtherSessionChanges, the changes from other sessions are automatically accepted instead of the local user's changes. If this argument is omitted, the conflict-resolution dialog box is displayed.

Possible Values are xlLocalSessionChanges - The local user's changes are always accepted, xlOtherSessionChanges - The local user's changes are always rejected, xlUserResolution - A dialog box asks the user to resolve the conflict.

AddToMru (Boolean) - True to add this workbook to the list of recently used files. The default value is False.

TextCodepage - Ignored for all languages in Microsoft Excel. NOTE: When Excel saves a workbook to one of the CSV or text formats, which are specified by using the FileFormat parameter, it uses the code page that corresponds to the language for the system locale in use on the current computer. This system setting is available in the Control Panel > Region and Language > Location tab under Current location

TextVisualLayout - Ignored for all languages in Microsoft Excel. NOTE: When Excel saves a workbook to one of the CSV or text formats, which are specified by using the FileFormat parameter, it saves these formats in logical layout. If left-to-right (LTR) text is embedded within right-to-left (RTL) text in the file, or vice versa, logical layout saves the contents of the file in the correct reading order for all languages in the file without regard to direction. When an application opens the file, each run of LTR or RTL characters are rendered in the correct direction according to the character value ranges within the code page (unless an application that is designed to display the exact memory layout of the file, such as a debugger or editor, is used to open the file)

Local - True saves files against the language of Microsoft Excel (including control panel settings). False (default) saves files against the language of Visual Basic for Applications (VBA) (which is typically US English unless the VBA project where Workbooks.Open is run from is an old internationalized XL5/95 VBA project)

WorkIdentity