View Single Post
 
Old 02-10-2025, 11:50 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I don't know the term for it (maybe self referencing) but I don't think you need to actually set a reference to the Applications Extensibility Library:

Code:
Sub ExportAllVBAModules()
'Late binding
Dim vbProj As Object
Dim vbComp As Object
Dim strFileName As String, strFilePath As String
Dim bExport As Boolean
  strFilePath = strFilePath = Environ("USERPROFILE") & "\Documents\" 'Path to export to.
  Set vbProj = ThisDocument.VBProject
  For Each vbComp In vbProj.VBComponents
    bExport = False
    Select Case vbComp.Type
      Case 1: strFileName = ReplaceInvalidChars(vbComp.Name) & ".bas": bExport = True
      Case 2: strFileName = ReplaceInvalidChars(vbComp.Name) & ".cls": bExport = True
      Case 3: strFileName = ReplaceInvalidChars(vbComp.Name) & ".frm": bExport = True
    End Select
    If bExport Then
      strFileName = strFilePath & strFileName
      vbComp.Export strFileName    ' Export the component.
      Debug.Print "Exported: " & vbComp.Name & " to " & strFileName
    End If
  Next vbComp
  MsgBox "All VBA modules exported to: " & strFilePath, vbInformation, "Export Complete"
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote