Hi
I am trying to copy a module containing a macro from one spreadsheet (copymod.xls) to another workbook (book1.xls) and then insert a button to run the macro I have just copied into book1.
Using the code below the macro runs from the copymod sheet and not the book1 sheet as I would like it to. I am quite new to VBA and don’t fully understand all the code yet.
Any help would be greatly appreciated.
Thanks in advance
I am trying to copy a module containing a macro from one spreadsheet (copymod.xls) to another workbook (book1.xls) and then insert a button to run the macro I have just copied into book1.
Using the code below the macro runs from the copymod sheet and not the book1 sheet as I would like it to. I am quite new to VBA and don’t fully understand all the code yet.
Any help would be greatly appreciated.
Thanks in advance
Code:
Sub copymod()
Workbooks.Add
Dim FName As String
With Workbooks("copymod")
FName = "C:\code.bas"
.VBProject.VBComponents("Module1").Export FName
End With
Workbooks("book1").VBProject.VBComponents.Import FName
Kill "C:\code.bas"
ActiveSheet.Buttons.Add(54.75, 32.25, 128.25, 61.5).Select
Selection.OnAction = "msg"
Application.CommandBars("Forms").Visible = False
Range("F8").Select
End Sub