Import/Export of VBA

A

Andy

Is there any mechanism or tools available to import and export all the
modules, forms etc from a Visio 2003 application. I am currently
exporting the files individually in order to do version control, but
this is becoming time consuming as the number of files grow.

Thanks
 
D

Dr. Stephan Kassanke

A

Andy

Thanks for that, after a few changes export works great.

Sub ExportVBAFiles()

Dim pVBAProject As VBProject
Dim vbComp As VBComponent 'VBA module, form, etc...
Dim strSavePath As String
Dim vdoDoc As Visio.Document


For Each vsoDoc In Visio.Documents

' Get the VBA project
' If you want to export code for Normal instead, paste this macro
into
' ThisDocument in the Normal VBA project and change the following
line to:
' Set pVBAProject = ThisDocument.VBProject

Set pVBAProject = vsoDoc.VBProject

strSavePath = "c:\sources\" & pVBAProject.name

On Error Resume Next

MkDir strSavePath On Error GoTo 0

' Loop through all the components (modules, forms, etc) in the
VBA project

For Each vbComp In pVBAProject.VBComponents

Select Case vbComp.Type

Case vbext_ct_StdModule
vbComp.Export strSavePath & "\" & vbComp.name &
".bas"

Case vbext_ct_Document, vbext_ct_ClassModule
' ThisDocument and class modules
Call vbComp.Export(strSavePath & "\" & vbComp.name &
".cls")

Case vbext_ct_MSForm
vbComp.Export strSavePath & "\" & vbComp.name &
".frm"

Case Else
vbComp.Export strSavePath & "\" & vbComp.name

End Select
Next

MsgBox "VBA files have been exported to: " & strSavePath

Next
End Sub
 
P

PKSpence

Where is VBProject and VBComponent? I'm using Visio EA and the intellisense
doesn't show this object.
 
P

PKSpence

Never mind... I needed to add a reference to "Microsoft Visual Basic for
Applications Extensibility" to the project
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top