Search notes:

Excel Object Model: Application

Methods and properties

activateMicrosoftApp() Activates or starts (another) Office application
activeCell Evaluates to the active cell
activeChart
activeEncryptionSession
activePrinter
activeProtectedViewWindow
activeSheet
activeWindow
activeWorkbook
addCustomList() See also customListCount, getCustomListContents(), deleteCustomList()
addIns
addIns2
alertBeforeOverwriting Controls if a message is displayed before a non-blank cell is overwritten during a drag-and-drop editing operation.
altStartupPath
alwaysUseClearType Can be used to overwrite a turned-off ClearType Windows Settings.
application
arbitraryXMLSupportAvailable
askToUpdateLinks If false, links are automatically updated, without first prompting the user (see the Ask to update automatic links option under File -> Options -> Advanced -> General
assistance Returns an IAssistance interface.
autoCorrect
autoFormatAsYouTypeReplaceHyperlinks
automationSecurity
autoPercentEntry
autoRecover
build
calculate() Re-calculates all open workbooks. Compare with the worksheet.calculate and range.calculate methods, and the calculation property.
calculateBeforeSave
calculateFull()
calculateFullRebuild()
calculateUntilAsyncQueriesDone() Runs all pending queries to OLEDB and OLAP data sources.
calculation A value of the xlCalculation enumeration: xlCalculationAutomatic (-4105), xlCalculationManual (-4135) or xlCalculationSemiautomatic (2))
calculationInterruptKey
calculationState
calculationVersion
caller
canPlaySounds compare with enableSound
canRecordSounds
caption
cellDragAndDrop
cells
centimetersToPoints() Converts a distance measured in centimeters to points (1 point = 0.035 centimeters). See also with inchesToPoints()
chartDataPointTrack
charts
checkAbort()
checkSpelling() Returns true if a word is found in a spell check dictionary (main or custom), false otherwise.
clipboardFormats
clusterConnector Specifies the name of a High Performance Computing (HPC) Cluster Connector (which is used to run user-defined functions in XLLs). See also useClusterConnector
columns
COMAddIns
commandBars
commandUnderlines
constrainNumeric
controlCharacters
convertFormula() converts formulas between reference styles (A1 or R1C1) and/or between relative and absolute addresses (see also range.address)
copyObjectsWithCells
creator
cursor
cursorMovement
customListCount see also addCustomList()
cutCopyMode
dataEntryMode Data entry mode prevents a user from entering data into locked cells of the currently selected Range.
DDEAppReturnCode
DDEExecute()
DDEInitiate()
DDEPoke()
DDERequest()
DDETerminate()
decimalSeparator The decimal separator character. See also thousandsSeparator, useSystemSeparators, range.numberFormatand the menu File -> Options -> Advanced -> Editing Options -> Use system separators.
defaultFilePath The default directory Excel shows when opening files
defaultSaveFormat
defaultSheetDirection
defaultWebOptions
deferAsyncQueries
deleteCustomList() Deletes a custom list. See lso addCustomList()
dialogs
display* See display properties
doubleClick() simlute a mouse-double-click on the active cell (which is equivalent to pressing the keyboard shortcut F2 and allows to edit the formula in the cell).
editDirectlyInCell
enableAnimations deprecated
enableAutoComplete
enableCancelKey
enableCheckFileExtensions
enableEvents controls whether an event triggers the corresponding event procedure.
enableLargeOperationAlert
enableLivePreview
enableMacroAnimations
enableSound Compare with canPlaySounds
errorCheckingOptions
evaluate() Converts a name to an object or a value. If the name is not dynamic, the shorthand [ … ] (square brackets) can be used.
excel4IntlMacroSheets
excel4MacroSheets
executeExcel4Macro()
extendList Specifies if formatting and formulas are extended to added list-data.
featureInstall
fileConverters
fileDialog
fileExportConverters
fileValidation Controls if files are validated (and possibly opened in Protected View) before opening a file. See also the ProtectedViewWindow object.
fileValidationPivot
findFile() Displays the open file dialog to open a file. Compare with getOpenFilename()
findFormat Find cells with a specific formatting
fixedDecimal
fixedDecimalPlaces
flashFill
flashFillMode
formulaBarHeight Sets the height of the Formula bar.
generateGetPivotData Controls the ability to get PivotTable reports.
generateTableRefs Controls if tables are referenced using the traditional or the new structured notation in formulas
getCustomListContents() see also customListCount, addCustomList()
getCustomListNum()
getOpenFilename() Displays the open file dialog to choose a file. Compare with getSaveAsFilename(), findFile()
getPhonetic()
getSaveAsFilename() Opens the standard Save as dialog and lets the user choose a file with it, yet without actually saving a file. Compare with getSaveAsFilename()
goto() allows to jump to a specific cell on a worksheet or a user defined VBA function
height The height of the main application window, measured in points.
help()
highQualityModeForGraphics
hinstance
hinstancePtr
hWnd
ignoreRemoteRequests
inchesToPoints() See centimetersToPoints()
inputBox() Displays a dialog to request input from the user.
interactive
international Returns locale related information.
intersect() Returns the intersection of one or more ranges. See Set operations
isSandboxed True if the workbook is open in a Protected View window.
iteration
languageSettings
largeOperationCellThousandCount
left
libraryPath
macroOptions()
mailLogoff()
mailLogon() Connect to MAPI Mail or Microsoft Exchange.
mailSession
mailSystem
mapPaperSize
mathCoprocessorAvailable
maxChange
maxIterations
measurementUnit
mergeInstances
mouseAvailable
moveAfterReturn Controls if the active cell is moved when the Enter key is pressed. If true, it moves to the direction specified in moveAfterReturnDirection
moveAfterReturnDirection
multiThreadedCalculation
name
names
networkTemplatesPath
newWorkbook
nextLetter()
ODBCErrors
ODBCTimeout
OLEDBErrors
onKey() Run the specified procedure when the given key or key-combination is pressed.
onRepeat()
onTime() Run a procedure at a given time or in a given period. Compare with wait
onUndo()
onWindow Specifies the name of the procedure that is executed when a window is activated.
operatingSystem The name of the OS on which this Excel installation runs.
organizationName
parent
path
pathSeparator
pivotTableSelection
previousSelections
printCommunication
productCode Returns the GUID for Excel.
promptForSummaryInfo
protectedViewWindows
quickAnalysis
quit()
range
ready
recentFiles
recordMacro()
recordRelative
referenceStyle
registeredFunctions
registerXLL() Registers the functions and commands that the specified XLL
repeat()
replaceFormat
rollZoom
rows
RTD Returns an RTD (Real Time Data) object
run() Runs a VBA-macro or a function.
saveWorkspace() deprecated
screenUpdating Controls if a workbook or worksheet is updated while a macro is running. Setting screenUpdating to false is generally believed to improve macro execution performance.
selection Returns the currently selected object. See also window.rangeSelection
sendKeys() Simulate pressing keys
sensitivityLabelPolicy
sharePointVersion() Returns the version of the SharePoint Foundation instances that are running at the specified URL
sheets
sheetsInNewWorkbook
showChartTipNames
showChartTipValues
showDevTools
showMenuFloaties Controls if mini toolbars should be displayed when a workbook-window is right clicked.
showQuickAnalysis
showSelectionFloaties
showStartupDialog
showToolTips
smartArtColors
smartArtLayouts
smartArtQuickStyles
speech Say (not write) Hello world!
spellingOptions
standardFont
standardFontSize
startupPath
statusBar The text in the Status bar.
templatesPath
thisCell The cell that initiated the execution of a user defined function.
thisWorkbook The workbook in (or from) which the «current» macro is being executed.
thousandsSeparator See also decimalSeparator, useSystemSeparators, range.numberFormat and the menu File -> Options -> Advanced -> Editing Options -> Use system separators.
top
transitionMenuKey
transitionMenuKeyAction
transitionNavigKeys
undo()
union()
usableHeight
usableWidth
useClusterConnector See clusterConnector
usedObjects All objects that are allocated in a workbook.
userControl false: Excel was started by createObject or getObject and is hidden. true: Excel was started «normally» or is visible.
userLibraryPath
userName
useSystemSeparators See also decimalSeparator, thousandsSeparator, range.numberFormat and the menu File -> Options -> Advanced -> Editing Options -> Use system separators.
value
VBE The «root object» of the VB Editor Object Model
version
visible
volatile() can be used to mark a user defined function as volatile which affects when this function is called for formula recalculation purposes.
wait() Pauses all Excel activity (excep printing and recalculation) for the given duration or the specified point in time. Compare with onTime
warnOnFunctionNameConflict
watches A watches object which represents a Range that is tracked when a worksheet is recalculated.
width
windows
windowsForPens
windowState Controls if the (active?) Window is maximized, minimized or shown normally.
workbooks
worksheetFunction Returns a WorksheetFunction object.
worksheets

display- properties

displayAlerts Controls if Excel prompts the user for a response using a message box or just assumes the action's default value.
displayClipboardWindow
displayCommentIndicator
displayDocumentActionTaskPane
displayDocumentInformationPanel
displayExcel4Menus
displayFormulaAutoComplete
displayFormulaBar Controls if the Formula bar is shown or hidden. Compare with formulaBarHeight
displayFullScreen
displayFunctionToolTips
displayInsertOptions
displayNoteIndicator
displayPasteOptions
displayRecentFiles
displayScrollBars
displayStatusBar
displayXMLSourcePane() Opens the XML Source task pane and displays the given XML map.

operatingSystem

application.operatingSystem returns some basic information about the Windows version and bitness, such as
Windows (32-bit) NT 6.01
See also VBA: 32-bit vs 64-bit

screenUpdating

The boolean screenUpdating controls if the screen is updated while a macro or function is running.
Turning it off can significantly improve performance if the function changes many values in a worksheet.
option explicit

sub main()

  Application.screenUpdating =  true
  call fill_10x40_rect(1, 1)
  
  Application.screenUpdating = false
  call fill_10x40_rect(1, 12)

end sub

sub fill_10x40_rect(startTopRow as long, startLeftColumn as long)

  dim t0, t1 as single
  dim r      as long
  dim c      as long
  
  t0 = timer
  for r = 0 to 39
  for c = 0 to  9
      cells(startTopRow + r, startLeftColumn + c).value = r * c
  next c
  next r
  t1 = timer
  
  debug.print "Filling 40 times 10 cells took " & (t1-t0) & " seconds."

end sub
Github repository about-MS-Office-object-model, path: /Excel/Application/screenUpdating.bas
Performance of macros/functions might also be improved by setting application.calculation to xlCalculationManual.
See also range.select.

sheetsInNewWorkbook

This value corresponds to the number of worksheets with which a new workbook is created.
This value is stored in the registry in the value DefSheets under the key HKEY_CURRENT_USER\Software\Microsoft\Office\_version_\Excel\Options.

showDevTools

The (read/write) boolean value of showDevTool corresponds to the visibility of the Developer tab in the Ribbon.

calculation

application.calculation can be set to one of the three enumeration values of xlCalculation:
xlCalculationAutomatic -4105 Excel automatically recalculates formulas
xlCalculationManual -4135 Recalculation of formulas needs to be requested by user (shortcuts with a combination of F9 and alt, ctrl, shift)
xlCalculationSemiautomatic 2 Automatic recalculation except for tables?
Setting calculation to xlCalculationManual might speed up macro/formula performance. Compare with the application.screenUpdating property.
See also formula recalculation.

active objects

The currently active woorkbook, woorksheet, cell (which is a range) and window can be found with the active* properties:
option explicit

sub main() ' {

    dim actCell     as range
    dim actWindow   as window
    dim actSheet    as worksheet
    dim actWorkbook as workbook

    set actWorkbook = application.activeWorkbook
    set actSheet    = application.activeSheet
    set actCell     = application.activeCell
    set actWindow   = application.activeWindow

    debug.print("Active workbook: " & actWorkbook.name )
    debug.print("Active sheet:    " & actSheet.name    )
    debug.print("Active cell:     " & actCell.address  )
    debug.print("Active window:   " & actWindow.caption)

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Application/activeObjects.bas
If multiple cells are selected, activeCell returns the top left selected cell.
If multiple worksheets are selected (see worksheet.select), assigning to or modifying activeCell is reflected in all respective cells of the selected workheets There is also
Some (all?) of these properties are defined in Excel's Global object.
Compare with thisWorkbook

thisWorkbook

thisWorkbook returns the workbook in which a macro is running.
Compare with activeWorkbook

functions

The application object exposes some functions that can be applied on ranges.
option explicit

sub main()

    dim val as double

    dim rng as range: set rng = range("a1:b5")

    fillTestData

    val = application.min    (rng) : debug.print "min = " & val
    val = application.sum    (rng) : debug.print "sum = " & val
    val = application.average(rng) : debug.print "avg = " & val

end sub

sub fillTestData()

    cells(1, 1) =  9: cells(1, 2) =  5
    cells(2, 1) =  2: cells(2, 2) =  8
    cells(3, 1) =  4: cells(3, 2) =  7
    cells(4, 1) =  5: cells(4, 2) =  5
    cells(5, 1) =  3: cells(5, 2) =  4

end sub
Github repository about-MS-Office-object-model, path: /Excel/Application/functions.bas
Compare with WorksheetFunction.

evaluate

Application.evaluate allows to dynamically evaluate Excel formulas (which in turn might call worksheet functions):
option explicit

sub main() ' {

    fillTestData

    evaluateFuncOnTestdata "sum"
    evaluateFuncOnTestdata "min"
    evaluateFuncOnTestdata "average"

end sub ' }

sub fillTestData() ' {

    cells(1, 1) =  9: cells(1, 2) =  5
    cells(2, 1) =  2: cells(2, 2) =  8
    cells(3, 1) =  4: cells(3, 2) =  7
    cells(4, 1) =  5: cells(4, 2) =  5
    cells(5, 1) =  3: cells(5, 2) =  4

end sub ' }

sub evaluateFuncOnTestdata(funcName as string) ' {

    debug.print funcName & " = " & application.evaluate(funcName & "(a1:b5)")

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Application/evaluate.bas
Brackets are a short hand notation for evaluate:
option explicit

sub main() ' {

    dim val as double

    fillTestData

    val = [min(a1:b5)]    : debug.print "min = " & val
    val = [sum(a1:b5)]    : debug.print "sum = " & val
    val = [average(a1:b5)]: debug.print "avg = " & val

end sub ' }

sub fillTestData() ' {

    cells(1, 1) =  9: cells(1, 2) =  5
    cells(2, 1) =  2: cells(2, 2) =  8
    cells(3, 1) =  4: cells(3, 2) =  7
    cells(4, 1) =  5: cells(4, 2) =  5
    cells(5, 1) =  3: cells(5, 2) =  4

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Application/brackets.bas
application.evaluate(formula) evaluates formula in the context of activeWorksheet. In order to evaluate a formula on a given sheet, worksheet.evaluate() should be used.
See also creating arrays with brackets.

match

Among other usages, match() can be used to test if an VBA array contains a given element.
The following example finds that baz is interesting, but bla is not.
option explicit

sub main() ' {

    dim interesting() as variant
        interesting = array("foo", "bar", "baz")
    
    if not isError(application.match("bla", interesting, 0)) then debug.Print "bla is interesting"
    if not isError(application.match("baz", interesting, 0)) then debug.Print "baz is interesting"

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Application/match.bas
It turns out that this example does not work with worksheetFunction.match().

caption

Apparently, the caption property can be used to bring an Excel application to the front:
appActivate application.caption

executeExcel4Macro

An example of how executeExcel4Macro might be used is to show or hide Excel's Ribbon

See also

Set operations for ranges: union and intersect.
The application object of the Office object model
The Excel Object Model

Index