CATIAV5 manages vba projects in specific files with extension .catvba
These projects are structured and behave like other VBAs: they have Modules, Forms and Classes. You can manually import export this VBA components, as you can do for example in Excel. But it seems that in CATIA you can't automate this operation, while this is possible in Excel using the "Microsoft Visual Basic For Applications Extensibility" module (as you can see here https://www.rondebruin.nl/win/s9/win002.htm).
I would like to achieve something similar in CATIAV5.
In other words, in order to have my .catvbas under version control I would like to:
- automate import/export of modules/classes/forms and "assemble" and "disassemble" them in a .catvba file programmatically.
By now I managed to add the Extensibility Library on a sample catvba project, and access the current project components for import or export.
'These references were added in the project:
'Microsoft APC Object Library
'Microsoft Visual Basic for Applications Extensibility
Sub main()
Dim oAPC As New Apc
Dim oVBE As VBE
Set oVBE = oAPC.VBE
Dim p As Project
Set p = oVBE.VBProjects.add(vbext_pt_HostProject)
'the instruction above throws error 440
Set p = oVBE.VBProjects.Open("C:\path\to\another\existing\project.catvba")
'the instruction above throws error 440, too
For Each comp In oAPC.VBE.ActiveVB.Project.VBComponent
Debug.Print comp.Name
'...export comp
Next
BUT STILL I'cant create a new catvba project, or open an existing one (error 440, see above). If I only could be able to open another project I could use it as an empty template to "fill"..