Anda di halaman 1dari 48

Object model

AboveAverage Object
Action Object
Actions Object
AddIn Object
AddIns Object
AddIns2 Object
Adjustments Object
AllowEditRange Object
AllowEditRanges Object
Application Object
Areas Object
AutoCorrect Object
AutoFilter Object
AutoRecover Object
Axes Object
Axis Object
AxisTitle Object
Border Object
Borders Object
CalculatedFields Object
CalculatedItems Object
CalculatedMember Object
CalculatedMembers Object
CalloutFormat Object
CategoryCollection Object
CellFormat Object
Characters Object
Chart Object
ChartArea Object
ChartCategory Object
ChartFormat Object
ChartGroup Object
ChartGroups Object
ChartObject Object
ChartObjects Object
Charts Object
ChartTitle Object
ChartView Object
ColorFormat Object
ColorScale Object
ColorScaleCriteria Object
ColorScaleCriterion Object
ColorStop Object
ColorStops Object
Comment Object
Comments Object
ConditionValue Object
Connections Object
ConnectorFormat Object
ControlFormat Object
CubeField Object
CubeFields Object
CustomProperties Object
CustomProperty Object
CustomView Object
CustomViews Object
Databar Object
DataBarBorder Object
DataFeedConnection Object
DataLabel Object
DataLabels Object
DataTable Object
DefaultWebOptions Object
Dialog Object
Dialogs Object
DialogSheetView Object
DisplayFormat Object
DisplayUnitLabel Object
DownBars Object
DropLines Object
Error Object
ErrorBars Object
ErrorCheckingOptions Object
Errors Object
FileExportConverter Object
FileExportConverters Object
FillFormat Object
Filter Object
Filters Object
Floor Object
Font Object
FormatColor Object
FormatCondition Object
FormatConditions Object
FreeformBuilder Object
FullSeriesCollection Object
Graphic Object
Gridlines Object
GroupShapes Object
HeaderFooter Object
HiLoLines Object
HPageBreak Object
HPageBreaks Object
Hyperlink Object
Hyperlinks Object
Icon Object
IconCriteria Object
IconCriterion Object
IconSet Object
IconSetCondition Object
IconSets Object
Interior Object
IRtdServer Object
IRTDUpdateEvent Object
LeaderLines Object
Legend Object
LegendEntries Object
LegendEntry Object
LegendKey Object
LinearGradient Object
LineFormat Object
LinkFormat Object
ListColumn Object
ListColumns Object
ListDataFormat Object
ListObject Object
ListObjects Object
ListRow Object
ListRows Object
Mailer Object
ModelChanges Object
ModelColumnChange Object
ModelColumnChanges Object
ModelColumnName Object
ModelColumnNames Object
ModelConnection Object
ModelFormatBoolean Object
ModelMeasureName Object
ModelFormatCurrency Object
ModelMeasureNames Object
ModelFormatDate Object
ModelRelationship Object
ModelFormatDecimalNumber Object
ModelRelationships Object
ModelFormatGeneral Object
ModelTable Object
ModelTableColumn Object
ModelFormatPercentageNumber Object
ModelTableColumns Object
ModelFormatScientificNumber Object
ModelTableNameChange Object
ModelFormatWholeNumber Object
ModelMeasure Object
ModelTableNameChanges Object
ModelTableNames Object
ModelTables Object
ModelMeasures Object
ModuleView Object
MultiThreadedCalculation Object
Name Object
Names Object
NegativeBarFormat Object
ODBCConnection Object
ODBCError Object
ODBCErrors Object
OLEDBConnection Object
OLEDBError Object
OLEDBErrors Object
OLEFormat Object
OLEObject Object
OLEObjects Object
Outline Object
Page Object
Pages Object
PageSetup Object
Pane Object
Panes Object
Parameter Object
Parameters Object
Phonetic Object
Phonetics Object
PictureFormat Object
PivotAxis Object
PivotCache Object
PivotCaches Object
PivotCell Object
PivotField Object
PivotFields Object
PivotFilter Object
PivotFilters Object
PivotFormula Object
PivotFormulas Object
PivotItem Object
PivotItemList Object
PivotItems Object
PivotLayout Object
PivotLine Object
PivotLineCells Object
PivotLines Object
PivotTable Object
PivotTableChangeList Object
PivotTables Object
PivotValueCell Object
PlotArea Object
Point Object
Points Object
ProtectedViewWindow Object
ProtectedViewWindows Object
Protection Object
PublishObject Object
PublishObjects Object
Queries Object
QueryTable Object
QueryTables Object
QuickAnalysis Object
Range Object
Ranges Object
RecentFile Object
RecentFiles Object
RectangularGradient Object
Research Object
RoutingSlip Object
RTD Object
Scenario Object
Scenarios Object
Series Object
SeriesCollection Object
SeriesLines Object
ServerViewableItems Object
ShadowFormat Object
Shape Object
ShapeNode Object
ShapeNodes Object
ShapeRange Object
Shapes Object
Sheets Object
SheetViews Object
Slicer Object
SlicerCache Object
SlicerCacheLevel Object
SlicerCacheLevels Object
SlicerCaches Object
SlicerItem Object
SlicerItems Object
SlicerPivotTables Object
Slicers Object
Sort Object
SortField Object
SortFields Object
SparkAxes Object
SparkColor Object
SparkHorizontalAxis Object
Sparkline Object
SparklineGroup Object
SparklineGroups Object
SparkPoints Object
SparkVerticalAxis Object
Speech Object
SpellingOptions Object
Style Object
Styles Object
Tab Object
TableObject Object
TableStyle Object
TableStyleElement Object
TableStyleElements Object
TableStyles Object
TextConnection Object
TextEffectFormat Object
TextFrame Object
TextFrame2 Object
ThreeDFormat Object
TickLabels Object
TimelineState Object
TimelineViewState Object
Top10 Object
TreeviewControl Object
Trendline Object
Trendlines Object
UniqueValues Object
UpBars Object
UsedObjects Object
UserAccess Object
UserAccessList Object
Validation Object
ValueChange Object
VPageBreak Object
VPageBreaks Object
Walls Object
Watch Object
Watches Object
WebOptions Object
Window Object
Windows Object
Workbook Object
WorkbookConnection Object
Workbooks Object
Worksheet Object
WorksheetDataConnection Object
WorksheetFunction Object
Worksheets Object
WorksheetView Object
XmlDataBinding Object
XmlMap Object
XmlMaps Object
XmlNamespace Object
XmlNamespaces Object
XmlSchema Object
WorkbookQuery Object
XmlSchemas Object
XPath Object
Enumerations

AllowEditRange Object (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Represents the cells that can be edited on a protected worksheet.

Remarks
Use the Add method or the Item property of the AllowEditRanges collection to return an AllowEditRange
object.

Once an AllowEditRange object has been returned, you can use the ChangePassword method to change the
password to access a range that can be edited on a protected worksheet.

Example
In this example, Microsoft Excel allows edits to range "A1:A4" on the active worksheet, notifies the user, then
changes the password for this specified range and notifies the user of this change.

VBA
Sub UseChangePassword()

Dim wksOne As Worksheet


Dim wksPassword As String

Set wksOne = Application.ActiveSheet

wksPassword = InputBox ("Enter password for the worksheet")

' Establish a range that can allow edits


' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:=wksPassword

MsgBox "Cells A1 to A4 can be edited on the protected worksheet."

' Change the password.

wksPassword = InputBox ("Enter the new password for the worksheet")

wksOne.Protection.AllowEditRanges(1).ChangePassword _
Password:=wksPassword

MsgBox "The password for these cells has been changed."

End Sub

AllowEditRange Object (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Represents the cells that can be edited on a protected worksheet.

Remarks
Use the Add method or the Item property of the AllowEditRanges collection to return an AllowEditRange
object.

Once an AllowEditRange object has been returned, you can use the ChangePassword method to change the
password to access a range that can be edited on a protected worksheet.

Example
In this example, Microsoft Excel allows edits to range "A1:A4" on the active worksheet, notifies the user, then
changes the password for this specified range and notifies the user of this change.

VBA
Sub UseChangePassword()

Dim wksOne As Worksheet


Dim wksPassword As String

Set wksOne = Application.ActiveSheet

wksPassword = InputBox ("Enter password for the worksheet")

' Establish a range that can allow edits


' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:=wksPassword

MsgBox "Cells A1 to A4 can be edited on the protected worksheet."

' Change the password.

wksPassword = InputBox ("Enter the new password for the worksheet")

wksOne.Protection.AllowEditRanges(1).ChangePassword _
Password:=wksPassword

MsgBox "The password for these cells has been changed."

End Sub

AllowEditRange.Delete Method (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Deletes the object.

Syntax
expression .Delete

expression A variable that represents an AllowEditRange object.

AllowEditRange.Range Property (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Returns a Range object that represents a subset of the ranges that can be edited edited on a protected worksheet.

Syntax
expression .Range

expression A variable that represents an AllowEditRange object.

AllowEditRange.Title Property (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Returns or sets the title of the range of cells that can edited on a protected sheet. Read/write String.

Syntax
expression .Title

expression A variable that represents an AllowEditRange object.

llowEditRange.Unprotect Method (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Removes protection from a sheet or workbook. This method has no effect if the sheet or workbook isn't
protected.

Syntax

expression .Unprotect(Password)

expression A variable that represents an AllowEditRange object.

Parameters
Data
Name Required/Optional Description
Type

A string that denotes the case-sensitive password to use to unprotect


Password Optional Variant the range of cells. If the range isn't protected with a password, this
argument is ignored.

llowEditRange.Users Property (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Returns a UserAccessList object for the protected range on a worksheet.

Syntax
expression .Users
expression A variable that represents an AllowEditRange object.

Example
In this example, Microsoft Excel displays the name of the first user allowed access to the first protected range
on the active worksheet. This example assumes that a range has been chosen to be protected and that a
particular user has been given access to this range.

VBA
Sub DisplayUserName()

Dim wksSheet As Worksheet

Set wksSheet = Application.ActiveSheet

' Display name of user with access to protected range.


MsgBox wksSheet.Protection.AllowEditRanges(1).Users(1).Name

End Sub
AllowEditRanges.Add Method (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Adds a range that can be edited on a protected worksheet. Returns a AllowEditRange object.

Syntax

expression .Add(Title, Range, Password)

expression A variable that represents an AllowEditRanges object.

Parameters
Name Required/Optional Data Type Description

Title Required String The title of range.

Range Required Range Range object. The range allowed to be edited.

Password Optional Variant The password for the range.

Return Value
An AllowEditRange object that represents the range.

Example

This example allows edits to range "A1:A4" on the active worksheet, notifies the user, then changes the
password for this specified range and notifies the user of this change.

VBA

Sub UseChangePassword()

Dim wksOne As Worksheet

Set wksOne = Application.ActiveSheet

' Protect the worksheet.


wksOne.Protect

' Establish a range that can allow edits


' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:="secret"
MsgBox "Cells A1 to A4 can be edited on the protected worksheet."

' Change the password.


wksOne.Protection.AllowEditRanges(1).ChangePassword _
Password:="moresecret"

MsgBox "The password for these cells has been changed."

End Sub

AllowEditRanges.Count Property (Excel)


Office 2013 and later
Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Returns a Long value that represents the number of objects in the collection.

Syntax
expression .Count

expression A variable that represents an AllowEditRanges object.

AllowEditRanges.Item Property (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Returns a single object from a collection.

Syntax
expression .Item(Index)

expression A variable that represents an AllowEditRanges object.

Parameters
Name Required/Optional Data Type Description

Index Required Variant The name or index number of the object.

Example

This example allows edits to range ("A1:A4") on the active worksheet, notifies the user, then changes the
password for this specified range and notifies the user of this change.

VBA

Sub UseChangePassword()

Dim wksOne As Worksheet

Set wksOne = Application.ActiveSheet

' Establish a range that can allow edits


' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:="secret"

MsgBox "Cells A1 to A4 can be edited on the protected worksheet."

' Change the password.


wksOne.Protection.AllowEditRanges.Item(1).ChangePassword _
Password:="moresecret"

MsgBox "The password for these cells has been changed."

End Sub
Application Object (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Represents the entire Microsoft Excel application.


Example

Use the Application property to return the Application object. The following example applies the Windows
property to the Application object.

VBA

Application.Windows("book1.xls").Activate
The following example creates a Microsoft Excel workbook object in another application and then opens a
workbook in Microsoft Excel.

VBA

Set xl = CreateObject("Excel.Sheet")
xl.Application.Workbooks.Open "newbook.xls"
Many of the properties and methods that return the most common user-interface objects, such as the active cell
(ActiveCell property), can be used without the Application object qualifier. For example, instead of writing

VBA

Application.ActiveCell.Font.Bold = True
You can write

VBA

ActiveCell.Font.Bold = True
Remarks

The Application object contains:

Application-wide settings and options.

Methods that return top-level objects, such as ActiveCell, ActiveSheet, and so on.

Events

Name

AfterCalculate

NewWorkbook

ProtectedViewWindowActivate

ProtectedViewWindowBeforeClose

ProtectedViewWindowBeforeEdit
ProtectedViewWindowDeactivate

ProtectedViewWindowOpen

ProtectedViewWindowResize

SheetActivate

SheetBeforeDelete

SheetBeforeDoubleClick

SheetBeforeRightClick

SheetCalculate

SheetChange

SheetDeactivate

SheetFollowHyperlink

SheetLensGalleryRenderComplete

SheetPivotTableAfterValueChange

SheetPivotTableBeforeAllocateChanges

SheetPivotTableBeforeCommitChanges

SheetPivotTableBeforeDiscardChanges

SheetPivotTableUpdate

SheetSelectionChange

SheetTableUpdate

WindowActivate

WindowDeactivate

WindowResize

WorkbookActivate

WorkbookAddinInstall
WorkbookAddinUninstall

WorkbookAfterSave

WorkbookAfterXmlExport

WorkbookAfterXmlImport

WorkbookBeforeClose

WorkbookBeforePrint

WorkbookBeforeSave

WorkbookBeforeXmlExport

WorkbookBeforeXmlImport

WorkbookDeactivate

WorkbookModelChange

WorkbookNewChart

WorkbookNewSheet

WorkbookOpen

WorkbookPivotTableCloseConnection

WorkbookPivotTableOpenConnection

WorkbookRowsetComplete

WorkbookSync

Methods

Name

ActivateMicrosoftApp

AddCustomList

Calculate
CalculateFull

CalculateFullRebuild

CalculateUntilAsyncQueriesDone

CentimetersToPoints

CheckAbort

CheckSpelling

ConvertFormula

DDEExecute

DDEInitiate

DDEPoke

DDERequest

DDETerminate

DeleteCustomList

DisplayXMLSourcePane

DoubleClick

Evaluate

ExecuteExcel4Macro

FindFile

GetCustomListContents

GetCustomListNum

GetOpenFilename

GetPhonetic

GetSaveAsFilename
Goto

Help

InchesToPoints

InputBox

Intersect

MacroOptions

MailLogoff

MailLogon

NextLetter

OnKey

OnRepeat

OnTime

OnUndo

Quit

RecordMacro

RegisterXLL

Repeat

Run

SendKeys

SharePointVersion

Undo

Union

Volatile
Wait

Properties

Name

ActiveCell

ActiveChart

ActiveEncryptionSession

ActivePrinter

ActiveProtectedViewWindow

ActiveSheet

ActiveWindow

ActiveWorkbook

AddIns

AddIns2

AlertBeforeOverwriting

AltStartupPath

AlwaysUseClearType

Application

ArbitraryXMLSupportAvailable

AskToUpdateLinks

Assistance

AutoCorrect

AutoFormatAsYouTypeReplaceHyperlinks

AutomationSecurity
AutoPercentEntry

AutoRecover

Build

CalculateBeforeSave

Calculation

CalculationInterruptKey

CalculationState

CalculationVersion

Caller

CanPlaySounds

CanRecordSounds

Caption

CellDragAndDrop

Cells

ChartDataPointTrack

Charts

ClipboardFormats

ClusterConnector

Columns

COMAddIns

CommandBars

CommandUnderlines

ConstrainNumeric
ControlCharacters

CopyObjectsWithCells

Creator

Cursor

CursorMovement

CustomListCount

CutCopyMode

DataEntryMode

DDEAppReturnCode

DecimalSeparator

DefaultFilePath

DefaultSaveFormat

DefaultSheetDirection

DefaultWebOptions

DeferAsyncQueries

Dialogs

DisplayAlerts

DisplayClipboardWindow

DisplayCommentIndicator

DisplayDocumentActionTaskPane

DisplayDocumentInformationPanel

DisplayExcel4Menus

DisplayFormulaAutoComplete
DisplayFormulaBar

DisplayFullScreen

DisplayFunctionToolTips

DisplayInsertOptions

DisplayNoteIndicator

DisplayPasteOptions

DisplayRecentFiles

DisplayScrollBars

DisplayStatusBar

EditDirectlyInCell

EnableAutoComplete

EnableCancelKey

EnableCheckFileExtensions

EnableEvents

EnableLargeOperationAlert

EnableLivePreview

EnableMacroAnimations

EnableSound

ErrorCheckingOptions

Excel4IntlMacroSheets

Excel4MacroSheets

ExtendList

FeatureInstall
FileConverters

FileDialog

FileExportConverters

FileValidation

FileValidationPivot

FindFormat

FixedDecimal

FixedDecimalPlaces

FlashFill

FlashFillMode

FormulaBarHeight

GenerateGetPivotData

GenerateTableRefs

Height

HighQualityModeForGraphics

Hinstance

HinstancePtr

Hwnd

IgnoreRemoteRequests

Interactive

International

IsSandboxed

Iteration
LanguageSettings

LargeOperationCellThousandCount

Left

LibraryPath

MailSession

MailSystem

MapPaperSize

MathCoprocessorAvailable

MaxChange

MaxIterations

MeasurementUnit

MergeInstances

MouseAvailable

MoveAfterReturn

MoveAfterReturnDirection

MultiThreadedCalculation

Name

Names

NetworkTemplatesPath

NewWorkbook

ODBCErrors

ODBCTimeout

OLEDBErrors
OnWindow

OperatingSystem

OrganizationName

Parent

Path

PathSeparator

PivotTableSelection

PreviousSelections

PrintCommunication

ProductCode

PromptForSummaryInfo

ProtectedViewWindows

QuickAnalysis

Range

Ready

RecentFiles

RecordRelative

ReferenceStyle

RegisteredFunctions

ReplaceFormat

RollZoom

Rows

RTD
ScreenUpdating

Selection

Sheets

SheetsInNewWorkbook

ShowChartTipNames

ShowChartTipValues

ShowDevTools

ShowMenuFloaties

ShowQuickAnalysis

ShowSelectionFloaties

ShowStartupDialog

ShowToolTips

SmartArtColors

SmartArtLayouts

SmartArtQuickStyles

Speech

SpellingOptions

StandardFont

StandardFontSize

StartupPath

StatusBar

TemplatesPath

ThisCell
ThisWorkbook

ThousandsSeparator

Top

TransitionMenuKey

TransitionMenuKeyAction

TransitionNavigKeys

UsableHeight

UsableWidth

UseClusterConnector

UsedObjects

UserControl

UserLibraryPath

UserName

UseSystemSeparators

Value

VBE

Version

Visible

WarnOnFunctionNameConflict

Watches

Width

Windows

WindowsForPens
WindowState

Workbooks

WorksheetFunction

Worksheets

EnableAnimations

Application.AfterCalculate Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

The AfterCalculate event occurs when all pending refresh activity (both synchronous and asynchronous) and
all of the resultant calculation activities have been completed.

Syntax

expression .AfterCalculate

expression A variable that represents an Application object.

Remarks

This event occurs whenever calculation is completed and there are no outstanding queries. It is mandatory for
both conditions to be met before the event occurs. The event can be raised even when there is no sheet data in
the workbook, such as whenever calculation finishes for the entire workbook and there are no queries running.

Add-in developers use the AfterCalculate event to know when all the data in the workbook has been fully
updated by any queries and/or calculations that may have been in progress.

This event occurs after all Worksheet.Calculate, Chart.Calculate, AfterRefresh, and SheetChange events. It
is the last event to occur after all refresh processing and all calc processing have completed, and it occurs after
Application.CalculationState is set to xlDone.
Application.NewWorkbook Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when a new workbook is created.

Syntax

expression .NewWorkbook(Wb)

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Wb Required Workbook The new workbook.

Example

This example arranges open windows when a new workbook is created.

VBA

Private Sub App_NewWorkbook(ByVal Wb As Workbook)


Application.Windows.Arrange xlArrangeStyleTiled
End Sub
Application.ProtectedViewWindowActivate Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when a Protected View window is activated.

Syntax

expression .ProtectedViewWindowActivate(Pvw, )

expression A variable that represents an Application object.

Parameters
Name Required/Optional Data Type Description

Pvw Required ProtectedViewWindow The activated Protected View window.

Return Value
Nothing

Remarks

For more information about how to use event procedures with the Application object, see Using Events with
the Application Object.

Application.ProtectedViewWindowBeforeClose Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs immediately before a Protected View window or a workbook in a Protected View window closes.

Syntax

expression .ProtectedViewWindowBeforeClose(Pvw, Reason, Cancel)

expression A variable that represents an Application object.

Parameters
Name Required/Optional Data Type Description
An object that represents the Protected View
Pvw Required ProtectedViewWindow
window that is closed.

A constant that specifies the reason the Protected


Reason Required XlProtectedViewCloseReason
View window is closed.

False when the event occurs. If the event


Cancel Required Boolean procedure sets this argument to True, the window
does not close when the procedure is finished.

Return Value
Nothing

Example

The following code example prompts the user for a yes or no response before closing the Protected View
window. This code must be placed in a class module and an instance of that class must be correctly initialized.
For more information about how to use event procedures with the Application object, see Using Events with
the Application Object.

VBA

Private Sub App_ProtectedViewWindowBeforeClose(ByVal Pvw as ProtectedViewWindow, _


Reason as XlProtectedViewCloseReason, Cancel as Boolean)
a = MsgBox("Do you really want to close the Protected View window?", _
vbYesNo)
If a = vbNo Then Cancel = True
End Sub
Application.ProtectedViewWindowDeactivate Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when a Protected View window is deactivated.

Syntax

expression .ProtectedViewWindowDeactivate(Pvw )

expression A variable that represents an Application object.


Parameters
Name Required/Optional Data Type Description

An object that represents the deactivated Protected View


Pvw Required ProtectedViewWindow
window.

Return Value
Nothing

Example

The following code example minimizes any Protected View window when it is deactivated. This code must be
placed in a class module and an instance of that class must be correctly initialized. For more information about
how to use event procedures with the Application object, see Using Events with the Application Object.

VBA

Private Sub App_ProtectedViewWindowDeactivate(ByVal Pvw As ProtectedViewWindow)


Pvw.WindowState = xlProtectedViewWindowMinimized
End Sub
pplication.ProtectedViewWindowOpen Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when a workbook is opened in a Protected View window.

Syntax

expression .ProtectedViewWindowOpen(Pvw, )

expression A variable that represents an Application object.

Parameters
Name Required/Optional Data Type Description

An object that represents the Protected View window that


Pvw Required ProtectedViewWindow
is opened.
Return Value
Nothing

Example

The following code example informs the user that the workbook will be opened in a Protected View window.
This code must be placed in a class module and an instance of that class must be correctly initialized. For more
information about how to use event procedures with the Application object, see Using Events with the
Application Object.

VBA

Private Sub App_ProtectedViewWindowOpen(ByVal Pvw As ProtectedViewWindow)


MsgBox "You are opening the following workbook in Protected View: " _
& Pvw.Caption
End Sub

Application.ProtectedViewWindowResize Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any Protected View window is resized.

Syntax

expression .ProtectedViewWindowResize(Pvw, )

expression A variable that represents an Application object.

Parameters
Name Required/Optional Data Type Description

An object that represents the resized Protected View


Pvw Required ProtectedViewWindow
window.

Return Value
Nothing

Application.ProtectedViewWindowResize Event (Excel)


Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any Protected View window is resized.

Syntax

expression .ProtectedViewWindowResize(Pvw, )

expression A variable that represents an Application object.

Parameters
Name Required/Optional Data Type Description

An object that represents the resized Protected View


Pvw Required ProtectedViewWindow
window.

Application.SheetActivate Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any sheet is activated.

Syntax

expression .SheetActivate(Sh, )

expression An expression that returns a Application object.


Parameters
Name Required/Optional Data Type Description

Sh Required Object The activated sheet. Can be a Chart or Worksheet object.

Application.SheetBeforeDelete Event (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs before any sheet is deleted.

Syntax

expression .SheetBeforeDelete(Sh, )

expression An expression that returns an Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The sheet. Can be a Chart or Worksheet object.

Application.SheetBeforeDoubleClick Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any worksheet is double-clicked, before the default double-click action.

Syntax

expression .SheetBeforeDoubleClick(Sh, Target, Cancel)

expression An expression that returns a Application object.


Parameters
Data
Name Required/Optional Description
Type

Sh Required Object A Worksheet object that represents the sheet.

Target Required Range The cell nearest to the mouse pointer when the double-click occurred.

False when the event occurs. If the event procedure sets this argument to
Cancel Required Boolean True, the default double-click action isn't performed when the procedure
is finished.

Application.SheetBeforeRightClick Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any worksheet is right-clicked, before the default right-click action.

Syntax

expression .SheetBeforeRightClick(Sh, Target, Cancel)

expression An expression that returns a Application object.

Parameters
Data
Name Required/Optional Description
Type

Sh Required Object A Worksheet object that represents the sheet.

Target Required Range The cell nearest to the mouse pointer when the right-click occurred.

False when the event occurs. If the event procedure sets this argument to
Cancel Required Boolean True, the default right-click action isn't performed when the procedure is
finished.

Application.SheetPivotTableBeforeAllocateChanges Event (Excel)


Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs before changes are applied to a PivotTable.

Syntax

expression .SheetPivotTableBeforeAllocateChanges(Sh, TargetPivotTable, ValueChangeStart,


ValueChangeEnd, Cancel)

expression A variable that represents a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The worksheet that contains the PivotTable.

TargetPivotTable Required PivotTable The PivotTable that contains the changes to apply.

The index to the first change in the associated


PivotTableChangeList collection. The index is specified
ValueChangeStart Required Long
by the Order property of the ValueChange object in the
PivotTableChangeList collection.

The index to the last change in the associated


PivotTableChangeList collection. The index is specified
ValueChangeEnd Required Long
by the Order property of the ValueChange object in the
PivotTableChangeList collection.

False when the event occurs. If the event procedure sets


Cancel Required Boolean this argument to True, the changes are not applied to the
PivotTable and all edits are lost.

Application.SheetPivotTableBeforeCommitChanges Event (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs before changes are committed against the OLAP data source for a PivotTable.

Syntax

expression .SheetPivotTableBeforeCommitChanges(Sh, TargetPivotTable, ValueChangeStart,


ValueChangeEnd, Cancel)

expression A variable that represents a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The worksheet that contains the PivotTable.

TargetPivotTable Required PivotTable The PivotTable that contains the changes to commit.

The index to the first change in the associated


PivotTableChangeList object. The index is specified by
ValueChangeStart Required Long
the Order property of the ValueChange object in the
PivotTableChangeList collection.

The index to the last change in the associated


PivotTableChangeList object. The index is specified by
ValueChangeEnd Required Long
the Order property of the ValueChange object in the
PivotTableChangeList collection.

False when the event occurs. If the event procedure sets


Cancel Required Boolean this argument to True, the changes are not committed
against the OLAP data source of the PivotTable.

Application.SheetPivotTableBeforeDiscardChanges Event (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs before changes to a PivotTable are discarded.

Syntax

expression .SheetPivotTableBeforeDiscardChanges(Sh, TargetPivotTable, ValueChangeStart,


ValueChangeEnd)

expression A variable that represents a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object

TargetPivotTable Required PivotTable The PivotTable that contains the changes to discard.

The index to the first change in the associated


PivotTableChangeList object. The index is specified by
ValueChangeStart Required Long
the Order property of the ValueChange object in the
PivotTableChangeList collection.

The index to the last change in the associated


PivotTableChangeList object. The index is specified by
ValueChangeEnd Required Long
the Order property of the ValueChange object in the
PivotTableChangeList collection.

Return Value
Nothing

Remarks

Occurs immediately before Excel executes a ROLLBACK TRANSACTION statement against the OLAP data
source, if a transaction is still active, and then discards all edited values in the PivotTable, after the user has
chosen to discard changes.

Application.SheetPivotTableUpdate Event (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs after the sheet of the PivotTable report has been updated.

Syntax

expression .SheetPivotTableUpdate(Sh, Target)

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The selected sheet.

Target Required PivotTable The selected PivotTable report.

Example

This example displays a message stating that the sheet of the PivotTable report has been updated. This example
assumes you have declared an object of type Application or Workbook with events in a class module.

VBA

Private Sub ConnectionApp_SheetPivotTableUpdate(ByVal shOne As Object, Target As


PivotTable)

MsgBox "The SheetPivotTable connection has been updated."

End Sub
pplication.SheetSelectionChange Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when the selection changes on any worksheet (doesn't occur if the selection is on a chart sheet).

Syntax

expression .SheetSelectionChange(Sh, Target)

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The worksheet that contains the new selection.

Target Required Range The new selected range.

Application.SheetTableUpdate Event (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when a table on a worksheet is updated.

Syntax

expression .SheetTableUpdate(Sh,Target)

expression A variable that represents a Application object.

Parameters
Name Required/Optional Data type Description

Sh Required OBJECT The worksheet.

Target Required TABLEOBJECT The table.

Application.SheetCalculate Event (Excel)

Office 2013 and later

Other Versions
Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs after any worksheet is recalculated or after any changed data is plotted on a chart.

Syntax

expression .SheetCalculate(Sh, )

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object Can be a Chart or Worksheet object.

Application.SheetChange Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when cells in any worksheet are changed by the user or by an external link.

Syntax

expression .SheetChange(Sh, Target)

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object A Worksheet object that represents the sheet.


Target Required Range The changed range.

Application.SheetDeactivate Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs when any sheet is deactivated.

Syntax

expression .SheetDeactivate(Sh, )

expression An expression that returns a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The sheet. Can be a Chart or Worksheet object.

Application.SheetLensGalleryRenderComplete Event (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs after a callout gallery?s icons (dynamic & static) have finished rendering.

Syntax

expression .SheetLensGalleryRenderComplete(Sh)

expression A variable that represents a Application object.


Parameters
Name Required/Optional Data type Description

Sh Required OBJECT Name of a worksheet.

Application.SheetPivotTableAfterValueChange Event (Excel)

Office 2013 and later

Other Versions

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA
documentation.

Occurs after a cell or range of cells inside a PivotTable are edited or recalculated (for cells that contain
formulas).

Syntax

expression .SheetPivotTableAfterValueChange(Sh, TargetPivotTable, TargetRange)

expression A variable that represents a Application object.

Parameters
Name Required/Optional Data Type Description

Sh Required Object The worksheet that contains the PivotTable

TargetPivotTable Required PivotTable The PivotTable that contains the edited or recalculated cells.

TargetRange Required Range The range that contains all the edited or recalcuated cells.

Return Value
Nothing

Remarks

The PivotTableAfterValueChange event does not occur under any conditions other than editing or
recalculating cells. For example, it will not occur when the PivotTable is refreshed, sorted, filtered, or drilled
down on, even though those operations move cells and potentially retrieve new values from the OLAP data
source.

Anda mungkin juga menyukai