You have to add a reference: "Microsoft Visual Basic for Applications
Extensibility 5.3" or something similar. Then you can analyze the VBA
project.
Here's some code I wrote to export the modules, classes, and forms in a
project, so that I could import them into VB:
Sub ExportComponents()
Dim v As VBIDE.VBProject
Dim c As VBIDE.VBComponent
Set v = ThisDocument.VBProject
For Each c In v.VBComponents
' Classes:
If Left(c.name, 4) = "CVis" Then
Call exportComponent(c)
End If
' Modules:
If c.name = "ShapeSheet" Then Call exportComponent(c)
If c.name = "LocaleInfo" Then Call exportComponent(c)
Next
End Sub
Private Sub exportComponent(vbcomp As VBIDE.VBComponent)
Dim sName As String, sExt As String
' Set the extension based on component type. Exit sub
' if type not supported.
Select Case vbcomp.Type
Case vbext_ct_ClassModule
sExt = ".cls"
Case vbext_ct_StdModule
sExt = ".bas"
Case Else
Exit Sub
End Select
' Build the name:
sName = ThisDocument.Path & vbcomp.name & sExt
' Save the file:
Call vbcomp.Export(sName)
End Sub
--
Hope this helps,
Chris Roth
Visio MVP