Copy a userform to a different workbook with VBA
Kuhni,
Just tried your code, works fine.
I don't think this is the problem as you gave line numbers, but did you put
ThisWorkbook.VBProject.VBComponents("FImport").Exp ort
Filename:="C:\temp.frm"
all on one line? Ditto 5?
Also, you should assign targetFile = "EK-Prices.xls". I didn't use that as I
had not yet saved them.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"kuhni" wrote in message
ups.com...
Bob,
Sure - here it is, but it is nearly identical to your code.
1 Sub copyForm()
2 Dim targetFile As String
3 targetFile = "EK-Prices"
4 ThisWorkbook.VBProject.VBComponents("FImport").Exp ort
Filename:="C:\temp.frm"
5 Workbooks(targetFile).VBProject.VBComponents.Impor t
Filename:="C:\temp.frm"
6 Kill "C:\temp.frm"
7 End Sub
The error occurs in line 4: Runtime Error 1004.
Thanks,
Kuhni
|