Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Excel 2003.
I have two open workbooks: one containing a macro and another workbook with no modules. I want to copy Module1 from the macro workbook to the other open workbook. I found some code that I tried to adapt but it is not working. Can someone tell me how to fix it? Do I need to add any specific references? Sub CopyModule() Dim strFolder As String Dim strTempFile As String Dim TargetWB As Workbook Dim SourceWB As Workbook Dim strModuleName As String strTempFile = "C:\test\" & "~tmpexport.bas" Set SourceWB = Workbooks("Book1") Set TargetWB = Workbooks("Book2") strModuleName = "Module1.bas" SourceWB.VBProject.VBComponents(strModuleName).Exp ort strTempFile TargetWB.VBProject.VBComponents.Import strTempFile Kill strTempFile End Sub -- Ken Hudson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy VBA Module to new workbook | Excel Programming | |||
Copy Module to new Workbook | Excel Programming | |||
?Module code copy | Excel Programming | |||
Copy a code module | Excel Programming | |||
Is it possible to copy a code module using VBA? | Excel Programming |