Stephan Dekker

If you are out to describe the truth, leave elegance to the tailor. (Albert Einstein, 1879 - 1955)

Export all the Excel 2007 modules to file

 

Create your own VBA module in Excel:

Sub exportAllModules()
    
     '  reference to extensibility library
    
    Dim objMyProj As VBProject
    Dim objVBComp As VBComponent
    
    Set objMyProj = Application.VBE.ActiveVBProject
    
    For Each objVBComp In objMyProj.VBComponents
        If objVBComp.Type = vbext_ct_StdModule Then
            objVBComp.Export "C:\temp\" & objVBComp.Name & ".bas"
        End If
    Next
    
End Sub

Add reference to:

Microsoft Visual Basic for Applications Extensibility

Give trust to the macros:

1. Open Excel 2007.
2. Click the Office Button (top-left most button in the window)
3. Click the Excel Options button.
4. Click Trust Center in the menu on the left.
5. Click Trust Center Settings in the window on the right.
6. In the new window that opens click Macros in the menu on the left.
7. Check the box next to Trust Access to the VBA project object model.
8. Click OK.
9. Click OK.
10. Close all Office applications and try your project again.

 

Happy days!

Published Wed, Dec 30 2009 2:54 AM by Stephan Dekker
Filed under: