Excel VBA Technology & Digital Applications 4 — Questions and Answers
Question 1: Which VBA class provides access to the Windows Registry for reading and writing keys?
- WScript.Shell via RegRead/RegWrite (Correct answer)
- Registry.Access object
- VBA.Registry class
- Windows.Reg object
Correct answer: WScript.Shell via RegRead/RegWrite
The WScript.Shell object exposes RegRead, RegWrite, and RegDelete methods for interacting with the Windows Registry from VBA.
Question 2: In VBA, what keyword prevents a variable declared in a standard module from being accessed by other modules?
- Private (Correct answer)
- Local
- Friend
- Dim
Correct answer: Private
Private restricts the variable's scope to the module in which it is declared, hiding it from all other modules.
Question 3: Which Excel object model property returns a Range representing all cells currently visible after applying filters?
- Range.SpecialCells(xlCellTypeVisible) (Correct answer)
- Range.FilteredCells
- AutoFilter.VisibleRange
- ListObject.VisibleRows
Correct answer: Range.SpecialCells(xlCellTypeVisible)
SpecialCells(xlCellTypeVisible) returns only the cells that are not hidden by row/column hiding or AutoFilter, enabling operations on filtered data.
Question 4: When using ADO in VBA to query an Excel workbook as a database, which connection string provider is used?
- Microsoft.ACE.OLEDB.12.0 (Correct answer)
- Microsoft.Jet.OLEDB.4.0
- SQLOLEDB
- Microsoft.Excel.OLEDB
Correct answer: Microsoft.ACE.OLEDB.12.0
The ACE OLEDB 12.0 provider supports .xlsx files; the older Jet 4.0 provider only supports .xls files.
Question 5: What VBA property of a Chart object allows you to programmatically change its chart type?
- Chart.ChartType (Correct answer)
- Chart.Type
- Chart.Kind
- Chart.Style
Correct answer: Chart.ChartType
The ChartType property accepts an XlChartType enum constant (e.g., xlLine, xlBar) to change the chart's visualization type.
Question 6: Which VBA function returns the number of bytes used by a variable or data type?
- LenB (Correct answer)
- Len
- SizeOf
- ByteLen
Correct answer: LenB
LenB returns the length in bytes rather than characters, making it useful for memory size calculations with Unicode strings.
Question 7: In Excel VBA, which method of the Workbook object saves a copy of the file to a new path without changing the active workbook's path?
- SaveCopyAs (Correct answer)
- SaveAs
- Export
- CopyTo
Correct answer: SaveCopyAs
SaveCopyAs saves a duplicate of the workbook to the specified filename while keeping the original workbook open and unchanged.
Which VBA class provides access to the Windows Registry for reading and writing keys?