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