+ Reply to Thread
Results 1 to 2 of 2

code to run when creating code from a template

  1. #1
    Registered User
    Join Date
    01-23-2008
    Posts
    4

    code to run when creating code from a template

    I have an Excel template that does almost what I want; there are formulas, etc., in it, and a VBA macro that writes out one of the worksheets as csv so that I can process it in another program.

    I would like something to run when I create an Excel file using this template that will get the current date and time, create part of a filename based on that, check to see if the file already exists, possibly ask the user whether to overwrite it, etc.

    I *think* what I want is for a macro to run when I create the workbook from the template. I am certainly willing to do it other ways, but the complexity of what I want to do suggests some VBA code, and the fact that it is based on an event similar to workbook-open leads me to think I'll end up with something like that.

    I've tried app_workbookopen; it doesn't run when I create file from the template, only when I open the template. I suppose if there's a way to have the macro run when the template is opened and a way for the resulting macro to create the file from the template, I might work it that way. It doesn't seem as clean, but again I'm willing to consider different methods.

    Anybody got ideas?

    tia,
    rc

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    Hi,
    This example might give you some leads
    look at the workbook code, and the module code
    http://www.freewebs.com/davesexcel/SaveMacro.xls

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1