+ Reply to Thread
Results 1 to 8 of 8

Macro to save a file with a pre file name + week number from a cell

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Macro to save a file with a pre file name + week number from a cell

    Hi there,

    i want to make a save as macro

    the save file needs to have a pre set filename but it needs to include the weeknumber from a cell
    in the cell i use a formula to get the weeknumber from a date.

    Example:
    when i click a macro button called Save File, there should be a save file created at a pre set location like a Desktop folder with a filename like Weeklist: including the weeknumber from lets say cell a1
    so the filename will be: Weeklist: 49.xls


    is it also possible to get the text of 2 different cell's
    example:
    a1 contains the weeknumber
    a2 contains the name of a person

    Filename will be Weeklist of: (a2) Week: (a1).xls

  2. #2
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Macro to save a file with a pre file name + week number from a cell

    Try this:
    Please Login or Register  to view this content.

    ... but, you can't use colons ( in file names.

  3. #3
    Registered User
    Join Date
    12-05-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to save a file with a pre file name + week number from a cell

    the code you send me does what i mean but i get an error in

    wb.SaveAs strFileName, FileFormat:=51

    Error: the following features can not be saved in macro-free workbooks?

  4. #4
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Macro to save a file with a pre file name + week number from a cell

    Oh, yeah, that'll happen if you are using ".xls" (FileFormat:=51) and the workbook has a macro in it. You can either switch to ".xlsm" (FileFormat:=52), or you can have the macro copy all the worksheets into a new book, without the macros, and do the SaveAs on the new workbook, instead. Simpler just to change the file extension in the name and the format in the existing, but pretty easy the other way, too.

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to save a file with a pre file name + week number from a cell

    Thnx it worked exactly as i wanted

  6. #6
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Macro to save a file with a pre file name + week number from a cell

    Wonderful! Glad I could help!

  7. #7
    Registered User
    Join Date
    11-26-2012
    Location
    Kitchener, Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Macro to save a file with a pre file name + week number from a cell

    >>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    aelgadi

    > Click Star if I helped. Thanks

  8. #8
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Macro to save a file with a pre file name + week number from a cell

    Yeah, click my star, too! :-)

+ 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