How do I copy a Form from one VBAProject to another

S

Sean

Hi,

I have an excel 'master' file that I'm basing a subset of
new files on. Basically I'm copying certain information
and programming from the master file into the new files.

My problem is that I have a Form in the master that I want
copied into the user files. How can I do this through
code?

Thanks!

Sean
 
C

Chip Pearson

Sean,

The following code will copy Userform1 from Book1.xls to
Book2.xls.

On Error Resume Next
Kill "H:\Form1.frm"
On Error GoTo 0
Workbooks("Book1.xls").VBProject.VBComponents _
("Userform1").Export Filename:="H:\Form1.frm"
Workbooks("Book2.xls").VBProject.VBComponents.Import _
Filename:="H:\Form1.frm"
Kill "H:\form1.frm"



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Thanks for the help! I eventually came up with a
variation on your suggestion (although yours is more
efficient!)
 
Top