Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a property in Office products which indicates custom VBA code

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
In Access you can check the HasModule property for a form. Is there an equivalent property in Excel, Word, etc?

Thanks in advance for any help you can give me!



 
The Access HasModule property only indicates the presence of a VBA code module; not that it was hand written (or wizard generated). It doesn't even have to include code at all.

John
 
Sorry, I misstated my question. As you noted, is there a property that indicates the presence of a VBA code module for Excel, Word, etc?

Thanks!

 
Not to my knowledge, but then I haven't really dabbled in Word/Excel/Powerpoint VBA at all.

There must be something though, because otherwise how would Excel/Word/Ppt itself know about the presence of the modules?

John
 
There is no built-in property. In excel all sheets and workbook have code modules, in word the document has code module.
To check other components, with reference to VBA Extensibility 5.3 you can, in excel (in office application should be the same, after chnging the top object to Workbooks(i), Documents(i), Presentations(i)):

[tt]Sub CountModules()
Dim c As VBComponent
Dim cCount(3) As Integer
For Each c In ThisWorkbook.VBProject.VBComponents
Select Case True
Case c.Type = vbext_ct_StdModule
cCount(1) = cCount(1) + 1
Case c.Type = vbext_ct_ClassModule
cCount(2) = cCount(2) + 1
Case c.Type = vbext_ct_MSForm
cCount(3) = cCount(3) + 1
End Select
Next
msg = "This workbook has:" & vbLf
msg = msg & cCount(1) & " module(s)," & vbLf
msg = msg & cCount(2) & " class module(s)," & vbLf
msg = msg & cCount(3) & " user form(s)." & vbLf
MsgBox msg
End Sub[/tt]

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top