Search notes:

Excel Object Model: Workbook

A Workbook object is the object that corresponds to an Excel file (*.xlsm, *.xlsx, etc.).
A workbook consists of multiple worksheets.
Each worksheet is uniquely identified by its name with the workbook.
The currently active workbook can be found with application.activeWorkbook.
The workbook in which a macro is running is returned by application.thisWorkbook.
A workbook has one corresponding VBProject in the VBE object model. It can be accessed by the vbProject property of the workbook.
A new workbook is created with application.workbooks.add.

Methods and properties

acceptAllChanges(), rejectAllChanges()
accuracyVersion
activate() Activates the first window that is associated with the workbook
activeChart
activeSheet
activeSlicer
addToFavorites()
application
applyTheme()
autoSaveOn
autoUpdateFrequency
autoUpdateSaveChanges
breakLink() Converts formulas that refer to other workbooks or OLE sources to values.
builtinDocumentProperties
calculationVersion
canCheckIn()
caseSensitive specify if text is compared case sensitively or case insensitively.
changeFileAccess()
changeHistoryDuration
changeLink() Replaces links that refer to a given workbook with links that refer to another workbook.
chartDataPointTrack
charts
checkCompatibility
checkIn()
checkInWithVersion()
close()
codeName
colors Sets or gets all or one of the 56 entries of the workbook's color palette.
commandBars returns a commandBars object
conflictResolution
connections A collection of workbookConnection objects.
connectionsDisabled
container
contentTypeProperties Returns a collection of MetaProperty objects which describe the workbook's metadata.
convertComments() Converts legacy comments and notes to modern comments.
createBackup If true, Excel automatically creates a backup when the workbook is saved (save())
createForecastSheet()
creator
customDocumentProperties
customViews
customXMLParts
date1904 specifies if the workbook uses the 1904 date system.
defaultPivotTableStyle
defaultSlicerStyle
defaultTableStyle
defaultTimelineStyle
deleteNumberFormat() Deletes a custom number format (TODO: range.numberFormat)
displayDrawingObjects
displayInkComments
documentInspectors
documentLibraryVersions
doNotPromptForConvert
enableAutoRecover
enableConnections() Enable data connections
encryptionProvider
endReview() See also sendForReview()
envelopeVisible
excel4IntlMacroSheets
excel4MacroSheets
excel8CompatibilityMode
exclusiveAccess()
exportAsFixedFormat() publishes the content of a workbook in the PDF or XPS format
fileFormat returns a document's format, an example is here. (See also saveAs)
final
followHyperlink()
forceFullCalculation
forwardMailer()
fullName path and filename of the workbook
fullNameURLEncoded URL encoded path and filename
getWorkflowTasks()
getWorkflowTemplates()
hasPassword Evaluates to true if the workbook is protected with a password.
hasVBProject true if the workbook has an associated VBA project
highlightChangesOnScreen Controls how changes are highlighted in a shared workbook.
highlightChangesOptions()
iconSets
inactiveListBorderVisible
isAddin true if the workbook is running as an Add-in.
isInplace
keepChangeHistory
linkInfo()
linkSources() Returns an array that contains the names of linked documents, editions, DDE or OLE servers.
listChangesOnNewSheet
lockServerFile()
mailer
mergeWorkbook() Merge changes from a workbook into an open workbook.
model
multiUserEditing
name read-only, use saveAs to set a workbook's name
names
newWindow() Creates a new window or a copy of the specified window. Compare with window.newWindow()
openLinks()
parent
password Gets or sets the password that is required to open the workbook.
passwordEncryptionAlgorithm
passwordEncryptionFileProperties
passwordEncryptionKeyLength
passwordEncryptionProvider
path
permission
personalViewListSettings
personalViewPrintSettings
pivotCaches() Returns a collection that contains all pivotCache objects of the workbook.
pivotTables
post()
precisionAsDisplayed
printOut()
printPreview()
protect(), unprotect()
protectSharing()
protectStructure
protectWindows
publishObjects
publishToDocs()
purgeChangeHistoryNow()
queries A collection of workbookQuery objects.
readOnly
readOnlyRecommended
refreshAll() Refreshes all external data ranges and pivotTable reports.
reloadAs()
removeDocumentInformation()
removePersonalInformation
removeUser() Disconnects the specified user from the shared workbook.
reply()
replyAll()
replyWithChanges()
research
resetColors() Reset the color palette to Excel's default color palette.
revisionNumber
runAutoMacros() calls a bunch of auto_ functions (which are considered obsolete in favor of workbook events)
save() See also the createBackup property.
saveAs() Saves the workbook and names it.
saveAsXMLData()
saveCopyAs()
saved
saveLinkValues
sendFaxOverInternet()
sendForReview() see also endReview()
sendMail()
sendMailer()
sensitivityLabel
serverPolicy
serverViewableItems
setLinkOnData()
setPasswordEncryptionOptions()
sharedWorkspace
sheets Evaluates to all, one or a selection of sheets in the workbook. Compare with .worksheets.
showConflictHistory
showPivotChartActiveFields
showPivotTableFieldList
signatures Returns a SignatureSet object (which is defined in Office's, not Excel's object model).
slicerCaches
smartDocument
styles
sync
tableStyles
templateRemoveExtData
theme
toggleFormsDesign()
unprotectSharing()
updateFromFile()
updateLink()
updateLinks
updateRemoteReferences
userStatus
useWholeCellCriteria
useWildcards
vBASigned true if the VBA project was digitally signed.
vBProject
webOptions
webPagePreview()
windows
worksheets The collection of worksheets that the workbook consists of. Compare with .sheets, excel4MacroSheets and excel4IntlMacroSheets
writePassword
writeReserved
writeReservedBy
xmlImport()
xmlImportXml()
xmlMaps
xmlNamespaces

fullName

fullName returns path and file name of the worksheet:
option explicit

sub main()

    debug.print activeWorkbook.fullName

end sub
Github repository about-MS-Office-object-model, path: /Excel/Workbook/fullName.bas
Compare with the Excel worksheet function cell(filename…).

forceFullCalculation

If forceFullCalculation is set to true, calculate() (on a worksheet object) will calculate every formula, regardless of dependencies.
When excel is restarted, forceFullCalculation will be reset to false again.

path

….path returns the directory where the respective workbook is stored.
Compare with application.path.

protect / unprotect

Calling protect protects a workbook. Optionally, the function can be given a password that is needed to unprotect it.
Apparently, a protected workbook just prevents adding, deleting, showing or hiding workhseets.
activeWorkbook.protect("secretPassword")
Repeal the protection:
activeWorkbook.unprotect("secretPassword")
Compare with the protect and unprotect methods of the → Microsoft/Office/Excel/Object-Model/Workbook[workbook object.
See also the menu Review -> Protect Workbook

refreshAll

A workbook's refreshAll() method refreshes (brings up to date) all data ranges and pivotTable reports in the respective workbook.
Object's whose backgroundQuery property is set to true are refreshed asynchronously.

saveAs

saveAs saves an excel document to disk and allows to specify the file name and file format.
option explicit

sub main() ' {

    activeWorkbook.saveAs _
       fileName   := environ("TEMP") & "\" & "bla.xlsm" , _
       fileFormat := xlOpenXMLWorkbookMacroEnabled

end sub ' }

'
'  vim: ft=vb
'
Github repository about-MS-Office-object-model, path: /Excel/Workbook/saveAs.bas

A file named … already exists in this location…

If the file name given to saveAs already exists, Excel will show the error message/warning A file named … already exists in this location. Do you want to replace it?
As far as I can tell, there is no way to prevent this error message other than deleting the file before writing it.

names

The names property refers to a collection that stores name objects.
See also Naming a range.

See also

A workbook might have a Model object.
SPREADSHEETCOMPARE.EXE is a tool that allows to compare two workbooks.
External data that is located in the workbook itself can be obtained using the information that is stored in a workbookConnection object.
If Book.xlt* is found in %appdata%\Microsoft\Excel\XLSTART, it is used as a template file for new workbooks being created.
Excel Object Model
The Worksheet function info("NUMFILE") evaluates to the number of active worksheets.
The Protect Workbook option under File -> Info controls the types of changes that users can make in a workbook.
Workbook events
The menu File -> Options -> General allows to specify some characteristics of new workbooks and worksheets when a new workbook is created (font, font size, default view and how many sheets are created).
The menu File -> Info -> Protect Workbook
A workbook can have (at most) one Data Model (but that model may contain multiple tables).
The Power Query standard library function Excel.CurrentWorkbook.

Index