Sub test()
'if FALSE then 2 possibilities
'1. no project
'2. locked project
MsgBox HasProject(Workbooks("test.xls"))
End Sub
Function HasProject(WB As Workbook) As Boolean
Dim WbProjComp As Object
On Error Resume Next
Set WbProjComp = WB.VBProject.VBComponents
If Not WbProjComp Is Nothing Then HasProject = True
End Function
I can not force any MVP to come here.Hi Erik,
I have found a solution, using interop application object, we can check if the workbook has VBproject associated with it or not. The property is called HASVBproject, it would be nice to know the answer of the MVP as well and do they have any comments on my findings.
Thanks
Sub test()
MsgBox HasProject(Workbooks("Book1.xls"))
End Sub
Function HasProject(WB As Workbook) As Boolean
Dim WbProjComp As String
On Error Resume Next
WbProjComp = WB.VBProject.Name
If Len(WbProjComp) > 0 Then HasProject = True
End Function