Excel VBA Technology & Digital Applications 3 — Questions and Answers
Question 1: Which VBA property of the Application object returns the version number of Excel currently running?
- Application.Version (Correct answer)
- Application.Build
- Application.Release
- Application.Edition
Correct answer: Application.Version
Application.Version returns a string like "16.0" representing the Excel version, useful for writing version-conditional code.
Question 2: In VBA, what does the Shell function return when it successfully launches an external application?
- The process ID of the launched application (Correct answer)
- True
- The application's window handle
- 0
Correct answer: The process ID of the launched application
Shell returns the process ID (a Double) of the program it started, or zero if the call failed.
Question 3: Which event fires when a workbook is opened and is the correct place to initialize application-level settings in VBA?
- Workbook_Open (Correct answer)
- Workbook_Activate
- Auto_Open
- Workbook_Initialize
Correct answer: Workbook_Open
Workbook_Open is the standard event procedure in ThisWorkbook that runs automatically when the file is opened.
Question 4: What VBA technique allows you to respond to events raised by objects not natively supported by the class module?
- WithEvents keyword in a class module (Correct answer)
- AddHandler statement
- RaiseEvent from a standard module
- Application.OnEvent method
Correct answer: WithEvents keyword in a class module
Declaring an object variable with WithEvents in a class module allows VBA to sink and respond to that object's events.
Question 5: When automating Outlook from Excel VBA, which object is the correct entry point to the Outlook object model?
- Outlook.Application (Correct answer)
- Outlook.Session
- Outlook.NameSpace
- Outlook.Explorer
Correct answer: Outlook.Application
Outlook.Application is the top-level object that provides access to all other Outlook objects such as NameSpace, Folders, and MailItem.
Question 6: Which VBA FileSystemObject method creates all intermediate directories needed for a given path?
- CreateFolder (Correct answer)
- MakeDir
- BuildPath
- MkDirAll
Correct answer: CreateFolder
FSO.CreateFolder creates a single folder; if intermediate folders are missing you must create them recursively, as there is no built-in MkDirAll equivalent.
Question 7: What is the purpose of the VBA statement 'DoEvents' when used inside a long-running loop?
- It yields control to the operating system so the UI remains responsive (Correct answer)
- It pauses execution for one second
- It forces Excel to recalculate all formulas
- It clears the event queue permanently
Correct answer: It yields control to the operating system so the UI remains responsive
DoEvents yields execution so Windows can process pending messages, keeping the Excel UI responsive during long loops.
Which VBA property of the Application object returns the version number of Excel currently running?