View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe 90[_2_] Joe 90[_2_] is offline
external usenet poster
 
Posts: 30
Default 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