View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Damien McBain[_2_] Damien McBain[_2_] is offline
external usenet poster
 
Posts: 49
Default Deleting a 'workbook' macro

"chiv" wrote in message
...

Good day all, I wonder if anyone has come across this before?

I have a 'private sub' macro which runs when a template is opened. The
utility of this is to assign an incremental Project ID to the template
each time it is opened. Obviously, the template is then saved under a
different name...as well as being saved as an .xls file.

The problem: The private sub code is still there when the new named
worksheet is opened and the increment still clicks up one number
everytime the sheet is opened. I have been trying to write code to
insert after the existing code in the .xlt file which will effectively
delete the code once the template has assigned a number.


You could create the new workbook based on another template (xls or xlt)
which has no VBA, save it with the filename you want and close the original
workbook (with the code) all in one hit. So the original workbook would run
the code then close and leave the new saved workbook active.