Your code worked fine for me.
Although, I would have used:
Set tmpWB = ActiveWorkbook
But that shouldn't matter to your code.
But I did get a different error if I don't allow programmatic access to the
workbook's project.
In xl2003 menus:
Tools|Macro|Security|trusted publishers
Check the bottom checkbox
N Selinger wrote:
I am trying to do this; in fact, I have done it before...somewhere. But, now
all I get is an error at the execution of the Export method, saying
"Application defined or object defined error". What is the problem? For
reference, here is my code snippet:
Dim tmpWB As Workbook
Set tmpWB = Workbooks(ActiveWorkbook.Name)
'assign a temporary workbook object
defloc = ActiveWorkbook.Path
'get active workbook path
tmpWB.VBProject.VBComponents("UserForm1").Export Filename:=defloc &
"\NACform.frm" 'save VBA form object
--
N Selinger
"Norman Jones" wrote:
Hi Mike,
Try something like:
'=============
Public Sub Tester()
Dim srcWB As Workbook
Dim destWb As Workbook
Const sStr As String = "C:\myFile.frm"
Set srcWB = Workbooks("MyBook1.xls")
Set destWb = Workbooks("MyBook2.xls")
srcWB.VBProject.VBComponents("Userform1").Export _
Filename:=sStr
destWb.VBProject.VBComponents.Import _
Filename:=sStr
Kill sStr
End Sub
'<<=============
For more informatoion on exporting / importing modules,
see Chip Pearson at:
Programming To The Visual Basic Editor
http://www.cpearson.com/excel/vbe.htm
---
Regards,
Norman
"MikeZz" wrote in message
...
Title says it all...
I'm using VBA to set up a new workbook.
I want the new workbook to have stand alone macros and user forms.
I can create the user forms and macros within the workbook that I'm
copying
from.
I just want to duplicate those into the new workbook.
Thanks!
--
Dave Peterson