How do I copy a Form from one VBAProject to another

  • Thread starter Thread starter Sean
  • Start date Start date
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
 
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
 
Thanks for the help! I eventually came up with a
variation on your suggestion (although yours is more
efficient!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top