Is This Content Helpful?
How can we make this better? Please provide as much detail as possible.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
This article shows how to save code in a VBA project to separate files.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic "Creating custom commands with VBA and UI Controls".
Dim myVBAProject As VBProject Dim vbComp As VBComponent Dim savePath As String 'Path to save exported files savePath = "D:\MyVBAFiles\" 'Get the VBA project from the document and 'loop through all the components 'in the VBA project Set myVBProject = Application.Document.VBProject For Each vbComp In myVBAProject.VBComponents Select Case vbComp.Type Case vbext_ct_StdModule vbComp.Export savePath & vbComp.Name & ".bas" Case vbext_ct_Document, vbext_ct_ClassModule vbComp.Export savePath & vbComp.Name & ".cls" Case vbext_ct_MSForm vbComp.Export savePath & vbComp.Name & ".frm" Case Else vbComp.Export savePath & vbComp.Name End Select Next