Is This Content Helpful?
We're glad to know this article was helpful.
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".
Code: 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