1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Use Current File Name But Add Data for Save

Discussion in 'Business Applications' started by jo15765, Oct 12, 2011.

Thread Status:
Not open for further replies.
  1. jo15765

    jo15765 Thread Starter

    Joined:
    Oct 11, 2011
    Messages:
    307
    I have a spreadsheet and I want to take the current file name (for this example let's say the file name is jo15765). I open the spreadsheet, refresh the data, and then I want to save it in this format...
    Code:
    & Format(Range("H11").Value) & "Current Name of Spreadsheet" & Format(Date, "mm-dd-yyyy") & ".xls"
    
    Is this possible?
     
  2. jo15765

    jo15765 Thread Starter

    Joined:
    Oct 11, 2011
    Messages:
    307
    I used this code and it is capturing the name of the current worksheet:
    Code:
    .SaveAs Filename:="C:\Documents and Settings\" & Format(Range("H11").Value) & "_" & ActiveWorkbook.Name & "_" & Format(Date, "mm-dd-yyyy") & ".xls"
    
    However, the current name of the spreadsheet is Test.xls. I want the .xls to be at the very end of the file name, is it possible to remove it?
     
  3. scotty718

    scotty718

    Joined:
    Nov 19, 2010
    Messages:
    185
    replace activeworkbook.name with left(activeworkbook.Name,instrrev(activeworkbook.Name,".")-1)

    this will ensure to remove the extension and will work if the filename has any other "." in, like dec.file.xls
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1021898

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice