+ Reply to Thread
Results 1 to 5 of 5

saving file in a macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    saving file in a macro

    How do I save the spreadsheet with the current name of the spreadsheet in a macro?

    Example:
    I want to save the spreadsheet to a network drive using the current name of the spreadsheet (it changes every other day). But I dont know to put the name in the SAVE statement. Here is what I have now:
    ActiveWorkbook.SaveAs Filename:="X:\DPR master.xlsm", FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    So it always saves as "DPR master". I need it to replace this with the current name of the spreadsheet.

    Thanks
    Last edited by jartzh; 12-08-2008 at 04:08 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
        ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name, _
                              FileFormat:=xlOpenXMLWorkbookMacroEnabled, _
                              CreateBackup:=False
    Please edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178
    Great,
    How do I specify a directory path?

    such as x:\pool\daily.

    when I specify it with:
    :#
        ChDir "X:\pool\Daily"
        ActiveWorkbook.SaveAs Filename:="x:\POOL\DAILY\" & ActiveWorkbook.Name, _
         FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    I get a file named "activeworkbook.name" on the correct folder.
    Last edited by jartzh; 12-08-2008 at 04:07 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    I get a file named "activeworkbook.name" on the correct folder.
    I don't see how if you're using the code you posted (which is still not in code tags as requested).

    Changing the directory and then saving the file in the now-current directory is redundant. Either
    ChDir "X:\pool\Daily"
    ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name, _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    ...or
    ActiveWorkbook.SaveAs Filename:="x:\POOL\DAILY\" & ActiveWorkbook.Name, _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

  5. #5
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178
    Works great.
    I dont know why it didnt work earlier, it looked the same.


    Sorry for the code tags. Now I got them tagged.


    Thanks, again

+ 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