Hi All,
Having some trouble exporting modules from code. Not sure why. Any help would be appreciated. I am getting Run-time error '50012' Method 'Export' of object '_VBComponent' failed. I am using an .xls workbook in Excel 2007.
My code is below, but the export breaks even when I do this:
Full Code Here:
Having some trouble exporting modules from code. Not sure why. Any help would be appreciated. I am getting Run-time error '50012' Method 'Export' of object '_VBComponent' failed. I am using an .xls workbook in Excel 2007.
My code is below, but the export breaks even when I do this:
Code:
strPath = "C:\ReplaceTaxCode"
ActiveWorkbook.VBProject.VBComponents("ToolsA").Export "\" & strPath
Code:
Public Sub ReplaceCode()
Dim wkbCode, wkbReplace As Workbook
Dim strPath
Dim VBAEditor As VBIDE.VBE
Dim objProject As VBIDE.VBProject
Dim objComponent As VBIDE.VBComponent
Set wkbCode = ThisWorkbook
Set VBAEditor = Application.VBE
Set objProject = VBAEditor.ActiveVBProject
strPath = "C:\ReplaceTaxCode"
For Each objComponent In objProject.VBComponents
objProject.VBComponents(objComponent.Name).Export "\" & strPath
Next
End Sub