+ Reply to Thread
Results 1 to 7 of 7

Macro to open a Template and save a new workbook

  1. #1
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Macro to open a Template and save a new workbook

    Hi guys,

    I would like to create a macro which opens a template and saves a COPY of the template as a new workbook in the same location of the template.

    What I had in mind was that when the macro is run the following will happen:

    • Step 1:Opens an already saved template from its location
    • Step 2: A Command Button pops up, prompting the user to insert the name of the new document (the new document will be copy of the template)
    • Step 3: The new document is saved as a macro-enabled workbook with the name inserted in step 2 above.

    Is this possible?

    Thanks a lot guys !
    Last edited by Keibri; 06-10-2015 at 03:01 AM.

  2. #2
    Registered User
    Join Date
    05-07-2015
    Location
    Angouleme, France
    MS-Off Ver
    2013
    Posts
    48

    Re: Macro to open a Template and save a new workbook

    Hello,

    of course it's possible, I dit it just a few days ago

    First I need to know if you launch the copy macro from another workbook than the one you want to copy.
    If it is the case, you don't have to open the said workbook.

    Here is a sample of how you can do this :
    Please Login or Register  to view this content.

    There you go ! Just tell me if it works or not, or if you don't understand something !

    François

  3. #3
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: Macro to open a Template and save a new workbook

    Hi AstroZelda thanks for your message. I am having some problems with the last line of the code, i.e. "FileCopy strTemplateFullName strCopyFullName"- cause it is giving me an error.

    If it is not too much of an inconvenience, could you kindly guide me accordingly

    Thanks a lot

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro to open a Template and save a new workbook

    Why not specify the template in Workbooks.Add?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: Macro to open a Template and save a new workbook

    Cheers!! That solved it out neatly!!!

    Thanks a lot !!

  6. #6
    Registered User
    Join Date
    05-07-2015
    Location
    Angouleme, France
    MS-Off Ver
    2013
    Posts
    48

    Re: Macro to open a Template and save a new workbook

    I forgot to write "As String" after the last variable, it may be what's causing the trouble. Otherwise, this method works fine for me ^^
    I'm glad you could solve your problem with Norie's solution, and sorry mine didn't work for you

    BTW, @Norie I didn't know you could set a template when using workbook.add, I am definitely keeping that method !

    Have a good day folks !

  7. #7
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: Macro to open a Template and save a new workbook

    Thanks for the follow up AstroZelda

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 06-26-2014, 03:13 PM
  2. Macro, copy UNLOCKED cell range of sheet in open workbook to workbook template
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-31-2012, 11:18 AM
  3. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  4. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM
  5. Replies: 0
    Last Post: 02-03-2006, 01:35 AM

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