Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default creating workbooks(with macros and userforms) programmatically

hi
I ve a template(.xlt) file.The file contains some macros and a use
form.When I open the xlt file i get the user form..

In some other workbook I ve written code to create new workbooks usin
the above mentioned template file as the template...

Though my code creates the new workbook but that workbook does not hav
the user form...

I want the userform to be available in each workbook I create...

Any one help pleas

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default creating workbooks(with macros and userforms) programmatically

I tried and gave up.

Why don't you instead start with a copy of a workbook that is empt
except for the VBA modules and form(s) and just make copies of tha
workbook?

It might not be as elegant as what you are doing, but it would be a lo
simpler

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default creating workbooks(with macros and userforms) programmatically

I put a userform in a new workbook. I put a button on a worksheet in that
workbook that showed the userform.

I saved that workbook as a template (and closed it).

Then in another workbook, I put this code:

Option Explicit
Sub testme()
Dim newWkbk As Workbook
Set newWkbk = Workbooks.Add(template:="c:\my documents\excel\book1.xlt")
End Sub

The new workbook based on this template had the userform and even worked when I
clicked on it.

If you're asking why the userform doesn't show when you create the new workbook,
try putting the code to show the userform in the Workbook_open event.

Or run the auto_open code in your code.

Option Explicit
Sub testme()
Dim newWkbk As Workbook
Set newWkbk = Workbooks.Add(template:="c:\my documents\excel\book1.xlt")
newWkbk.RunAutoMacros which:=xlAutoOpen
End Sub



"amitkr <" wrote:

hi
I ve a template(.xlt) file.The file contains some macros and a user
form.When I open the xlt file i get the user form..

In some other workbook I ve written code to create new workbooks using
the above mentioned template file as the template...

Though my code creates the new workbook but that workbook does not have
the user form...

I want the userform to be available in each workbook I create...

Any one help please

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
help creating new hyperlinks programmatically J Links and Linking in Excel 1 January 14th 08 08:15 AM
Userforms and Macros cinvic Excel Discussion (Misc queries) 2 March 15th 06 08:06 PM
Creating UserForms Victor New Users to Excel 1 July 8th 05 07:57 PM
Storing macros, userforms Jennifer Excel Discussion (Misc queries) 0 April 5th 05 07:57 AM
Creating Sub CommandButton1_Clk programmatically Jag Man Excel Programming 7 December 14th 03 08:49 PM


All times are GMT +1. The time now is 06:55 PM.

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"