Excel VBA Tutorial : Workbook Events and Procedures

Today we will learn about Workbook Events and Procedures

Workbook Activate Event

This event will run code whenever this specific workbook is activated.

Workbook AddinInstall Event

This event will run when the specific workbook is installed as Add-In in Excel.

Workbook AddinUninstall Event

This event will run when this workbook is uninstalled from Excel’s Add-Ins.

VBA Functions You Can’t Live Without

Workbook AfterSave Event

This Event will run after the specific workbook is saved.

Required Parameters

Success – The success parameter is a Boolean data type that will return a value of true if the workbook successfully saved. If the workbook failed to save then the success parameter will return a value of false.

Workbook AfterXmlExport EventThis event will run after exporting XML map within an excel workbook.

Required Parameters

Map – The map parameter returns the exported XML map as an XMLMap object. This allows users to manipulate the XML map or display various XML map attributes.

URL – The URL parameter returns the a string location of where the XML map is being saved to.

Result – The result parameter returns a value of true if the XML map successfully saved and a value of false if the value failed to save properly.

Ten Tips For Coding Excel VBA Macros

Workbook AfterXmlImport Event

This event will run after importing a new or refreshing an already created XML map within this specific excel workbook.

Required Parameters

Map – The map parameter returns the exported XML map as an object. This allows users to manipulate the object or display various attributes.

IsRefresh – The IsRefresh parameter returns a value of True if the XML map is being refreshed and returns a value of false if the map is being imported for the first time.

Result – The result parameter can return three different values. If the XML being refreshed or imported contains too much data to fit into the workbook then the result parameter will return the value of xlXmlImportElementsTruncated. If the XML being refreshed or imported is successful then the result parameter will return a value of xlXmlImportSuccess. If the XML being refreshed or imported does not match the XML schema specified then the result parameter will return a value of xlXmlImportValidationFailed.

Learn to optimize calculation time of worksheet data in VBA

Workbook BeforeClose Event

This event will run before a workbook closes.

Required Parameters

Cancel – The cancel parameter is original set to False when the event begins. If the cancel parameter is set to value of True then the workbook will not close.

Workbook BeforePrint Event

This event will run before a workbook prints.

Required Parameters

Cancel – The cancel parameter is original set to False when the event begins. If the cancel parameter is set to value of True then the workbook will not print.

How to convert Numbers to Words in Indian Currency Format – VBA Macros

1

No Responses

Show all responses

Write a response