LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default How to use templates with macros

Hello,
I have a template which I used for years with excel 2003, and now it
doesn't work with excel 2007. This template has macros in it, and a
couple active buttons which when pressed, create a non-template file
based on the template prototype. The new non-template file also has
macros in it. So, when I try to run the file as a template, I get an
error that says that I cannot save the file into a macro-free
workbook.

I have tried saving my template as an xltm, and I have tried re-
writing the macro so that it saves the new file as an xlsm (macro-
enabled workbook). I cannot get this to work, and I am beginning to
believe that this is one of the flaws of excel 2007 (I wish so much
that microsoft would have simply billed us twice for excel 2003
instead of forcing us to use the security-obsessed 2007).
Anyway...please excuse my rant. This macro/template works perfectly
fine if I use it as an xls file. But I would prefer to have it run as
a macro so that people cannot accidentally edit the template file.

Can anyone explain to me how to make this VB code into a template.
This is based on an on screen button. Implementing this will cause
the same error I have been getting. If you can figure this out, I
would appreciate it.

Private Sub CommandButton1_Click()
Cells(1, 1) = "template works"
ThisWorkbook.SaveAs "template-enabled-workbook.xlsm"
End Sub

OR... try this

Private Sub CommandButton1_Click()
Cells(1, 1) = "template works"
ThisWorkbook.SaveAs "template-enabled-workbook.xls"
End Sub

thanks
 
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
macros and templates James O[_2_] Excel Discussion (Misc queries) 4 April 24th 07 02:34 AM
Need help with macros and formatting templates in Excel SuzyQ Excel Worksheet Functions 1 December 15th 06 07:35 AM
macros Vs templates mita Excel Discussion (Misc queries) 1 April 4th 06 08:17 PM
Formatting (macros or templates)? Sligerk Excel Discussion (Misc queries) 0 November 14th 05 04:21 PM
Email templates & Excel Macros Andrew[_27_] Excel Programming 2 February 20th 04 06:29 AM


All times are GMT +1. The time now is 01:45 AM.

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

About Us

"It's about Microsoft Excel"