+ Reply to Thread
Results 1 to 10 of 10

Modify macro to save with current file name and date

  1. #1
    Registered User
    Join Date
    10-26-2011
    Location
    Houston, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Modify macro to save with current file name and date

    I am placing a macro in excel to save a file to our network. It works but it always saves it as a fixed document name. I would like to modify it so I can use it in a blank template. I would like to have the macro save the file under what ever the current document name is with the date the file was saved.



    Please Login or Register  to view this content.
    Last edited by rockhunter; 10-28-2011 at 10:00 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modify macro to save with current file name and date

    I wouldn't expect to save as *.xltm but *.xlsm" or *.xlsx
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-26-2011
    Location
    Houston, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Modify macro to save with current file name and date

    That works fantastic! I had one more thing I would like it to do. This code saves the file with the same name for example "test save macro (date).xltm. If I saved the document with a different name can I get the macro to save the file with what ever document I name it?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modify macro to save with current file name and date

    Try
    Please Login or Register  to view this content.
    You are saving as a template file though

  5. #5
    Registered User
    Join Date
    10-26-2011
    Location
    Houston, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Modify macro to save with current file name and date

    That works AWESOME! Thank you very much!
    I know we are saving in template format. For some reason if we don't save it in that format we have macro funtion problems when a couple of the other people who access this file save it as a document. This way it works for everyone, we don't know why it only effects some people and not others yet.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modify macro to save with current file name and date

    You really have the wrong file format, have you tried .xlsx?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Registered User
    Join Date
    10-26-2011
    Location
    Houston, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Modify macro to save with current file name and date

    I will test that one. We were saving as macro enabled workbook .xlsm but that only worked for some of the people not everyone.

  8. #8
    Registered User
    Join Date
    10-26-2011
    Location
    Houston, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Modify macro to save with current file name and date

    I had an additional question to add to this thread and I hope I can explain what I want to do clearly. I would like to see if I can make the macro look for a directory typed into a cell in the work book on where to save the file on the network drive. Thank you royUK for helping me the date and name previously on this macro.

    Say I have some cell (B:9) that has one of the follwoing locations on the netowrk I want to save the file to.
    Example
    K:\OPERATIONS GEO\Backup of Cross Sections\project 1\
    or
    K:\OPERATIONS GEO\Backup of Cross Sections\project 2\

    can I get the macro reference the cell (B:9)?

    Please Login or Register  to view this content.
    Last edited by Paul; 10-28-2011 at 01:59 PM. Reason: Added CODE tags

  9. #9
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Modify macro to save with current file name and date

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Also - please don't create never-ending threads. If you have a new question, start a new thread.

    Thanks!

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modify macro to save with current file name and date

    You need to read about Variables & how to use them

    Please Login or Register  to view this content.

+ 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