Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How do I copy a Form from one VBAProject to another

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How do I copy a Form from one VBAProject to another

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.Impo rt _
Filename:="H:\Form1.frm"
Kill "H:\form1.frm"



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




"Sean" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default How do I copy a Form from one VBAProject to another

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


-----Original Message-----
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.Imp ort _
Filename:="H:\Form1.frm"
Kill "H:\form1.frm"



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




"Sean" wrote in

message
...
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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBAProject Andy Excel Worksheet Functions 1 January 10th 05 02:53 PM
How to get rid of a VBAProject? GF[_2_] Excel Programming 1 February 20th 04 03:10 PM
VBAProject Protect Kevin Excel Programming 3 November 17th 03 06:50 PM
code in VBAProject will not run Mike[_58_] Excel Programming 2 November 9th 03 04:08 PM
How to Delete a VBAProject JStone0218 Excel Programming 1 November 8th 03 02:47 PM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"