I don't have a complete answer for you, but maybe you can work something out from this blog post by Han Yong:
It's about indexing pdi files as text files, in order to search within them. Try it out - with one pdi WITH vba code, and one WITHOUT vba code. See if you're able to find a method name or definition to determine if there's vba code present.
Matt, You need to add a reference to Visual Basic for Applications Extensibility then you can check.
You access the VBE property of the ProcessBook application, then the "ThisDisplay" VBComponent and finally the CodeModule where you have a property "CountOfLines". Basic example:
Function HasVBA(ByVal TheDisplay As Display) As Boolean
Dim ret As Boolean: ret = False
Dim VBE As VBE: Set VBE = TheDisplay.Application.VBE
Dim VBC As VBComponent: Set VBC = VBE.ActiveVBProject.VBComponents("ThisDisplay").Name
ret = (VBC.CodeModule.CountOfLines > 0)
HasVBA = ret
Obviously, if there is more than 1 VBComponent then you need to check those too for VBA code (e.g. a Module or Class object).
Thanks for the information. I didn't know about VBE and your example helped me research how to write this application. Attached is an application I wrote that will extract all code from a ProcessBook file. I didn't put any error handling or anything in there so use at your own risk!
pb_vba_extractor.zip 74.1 KB
No problem Matt.
I have a library of controlled ProcessBook displays that I can search every line of VBA, add/remove VBA methods at will from one central location using VBE - works a treat!
is this lib you tell about free for use or your private secret? :-)