PC Review


Reply
Thread Tools Rate Thread

How do I determine if a workbook is a template?

 
 
=?Utf-8?B?Q2xheW1hbg==?=
Guest
Posts: n/a
 
      5th Jul 2007
I have code that needs only execute when a template is opened. The code saves
the template as .xls, and in that state the code should not execute. I
thought about deleting the code when the template is saved as a sheet,
--
Adios,
Clay Harryman
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2xheW1hbg==?=
Guest
Posts: n/a
 
      5th Jul 2007
Oops - please disregard. Accidentally hit "Post" instead of "Close". Dang -
those buttons are close together...
--
Adios,
Clay Harryman


"Clayman" wrote:

> I have code that needs only execute when a template is opened. The code saves
> the template as .xls, and in that state the code should not execute. I
> thought about deleting the code when the template is saved as a sheet,
> --
> Adios,
> Clay Harryman

 
Reply With Quote
 
=?Utf-8?B?Q2xheW1hbg==?=
Guest
Posts: n/a
 
      6th Jul 2007
Prob'ly oughta post the solution I found:

The code in the template saves it as *.xls. Problem is, XL didn't recognize
it as a regular workbook, still as a template. Had to add this to the SaveAs:

ThisWorkbook.SaveAs _
Filename:=fname _
password:="xxxxxx" _
FileFormat:=xlWorkbookNormal

The last parameter is what makes XL recognize it as a "normal" workbook.

Then, at the top of the code, I added this line:

If ThisWorkbook.FileFormat <> xlTemplate Then Exit Sub

Voila! The code won't be executed if it's not a template!

I'm outtahere!
--
Adios,
Clay Harryman


"Clayman" wrote:

> I have code that needs only execute when a template is opened. The code saves
> the template as .xls, and in that state the code should not execute. I
> thought about deleting the code when the template is saved as a sheet,
> --
> Adios,
> Clay Harryman

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy & Paste from One Workbook to a Macroed Template Workbook VickiMc Microsoft Excel Programming 1 21st Sep 2009 09:52 AM
Determine Workbook Mode =?Utf-8?B?TWlrZSBILg==?= Microsoft Excel Programming 1 26th Sep 2007 05:31 PM
Determine if a workbook is already open =?Utf-8?B?aHpndDliQG5vcG9zdC5jb20=?= Microsoft Excel Programming 6 28th Feb 2007 04:05 PM
Determine if a workbook is shared =?Utf-8?B?cXVhcnR6?= Microsoft Excel Programming 3 2nd Mar 2004 10:23 PM
How to open workbook from workbook template without hardcoding Michael Turner Microsoft Excel Misc 1 21st Nov 2003 02:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 AM.