ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Updating VBA Modules and Forms in User Workbooks (https://www.excelbanter.com/excel-programming/296645-updating-vba-modules-forms-user-workbooks.html)

Joe 90[_2_]

Updating VBA Modules and Forms in User Workbooks
 
Hi

Have found this code through the newsgroup, that appeared to achieve what I
want to do:

Sub CopyAllModules()

Dim FName As String
Dim VBComp As VBIDE.VBComponent

With Workbooks("one.xls")
FName = .Path & "\code.txt"
If Dir(FName) < "" Then
Kill FName
End If
For Each VBComp In .VBProject.VBComponents
If VBComp.Type < vbext_ct_Document Then
VBComp.Export FName
Workbooks("Two.xls").VBProject.VBComponents.import FName ' **
Kill FName
End If
Next VBComp
End With

End Sub

However it crashes on the import line (**). It seems that this code will
only export/import the modules which can be converted to text files. I need
to update user spreadsheets with both modules and FORMS. What additions to
this code do I need. VBA help is less than useful with regard to working
with project elements. ( I am referencing "Microsoft Visual Basic for
Application Extensibility 5.3")

Any help here gratefully received.

Joe90



All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com