Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Tallinn, Harjumaa, Estonia
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    run code while creating new workbook from template

    (Excel 2000)
    I'd like to force user to save new documents first if heshe uses certain template. This works fine in word with Document_new event.
    I cannot find anything equal in excel.
    NewWorkbook event doesn't occur while creating new worbook from template, but choosing file|new from menu.
    ThisWorkbook doesn't have New event.

    Have anybody idea how to do that

    Thanks for advance,
    Anu

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run code while creating new workbook from template

    Use the Workbook_open event in the Thisworkbook module.

    In Excel, when a workbook is created using a template, everything including all code gets copied from the template into the new workbook and there is NO connection between the template and the workbook it was created from.

    In principle what happens is that a copy of the template is created and its name is changed to something like TheNameOfTheTemplate1.xls
    The Workbook_Open event of the newly created book should fire then.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Tallinn, Harjumaa, Estonia
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run code while creating new workbook from template

    Many thanks!!

    Its really confusing.

    As you suggested I examined the name property and applied the fact that the worksheet.name has no extension while the new document is not saved yet.

    If ext <> ".xls" And ext <> ".xlt" Then
    Call subNewWorkbook
    End If

    Anu

Posting Permissions

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