lior03
07-03-2005, 12:48 PM
Took advantage of a procedure I found in cpearson site.
The aim is to copy the entire vba code of a workbook to another.
The new code is
Sub CopyAllModules2()
Dim FName As String
Dim VBComp As VBIDE.VBComponent
Dim x As String
x = InputBox("specify workbook")
With ActiveWorkbook
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(x).VBProject.VBComponents.Import FName
Kill FName
End If
Next VBComp
End With
End Sub
I want the user to specify to which workbook he wants to copy.
many thanks
The aim is to copy the entire vba code of a workbook to another.
The new code is
Sub CopyAllModules2()
Dim FName As String
Dim VBComp As VBIDE.VBComponent
Dim x As String
x = InputBox("specify workbook")
With ActiveWorkbook
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(x).VBProject.VBComponents.Import FName
Kill FName
End If
Next VBComp
End With
End Sub
I want the user to specify to which workbook he wants to copy.
many thanks