ou81aswell
Board Regular
- Joined
- Oct 6, 2009
- Messages
- 50
Is there a way to determine programatically if a workbook contains macros / VBA without having the "Trust access to VBA project" option checked?
Thanks!
Thanks!
Function TestForVBComponents(wbkName As String) As Boolean
Dim VBCodeMod As Object
Dim ctAll As Long, ctMods As Long, ctShts As Long
Application.Volatile
ctAll = Workbooks(wbkName).VBProject.VBComponents.Count
ctShts = Workbooks(wbkName).Sheets.Count
ctMods = ctAll - ctShts - 1 '-1 for ThisWorkbook component
If ctMods > 0 Then
TestForVBComponents = True
Else
TestForVBComponents = False
End If
End Function