Results 1 to 12 of 12

Rename file with saveas using string variables in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    03-28-2015
    Location
    Miami Beach, Florida
    MS-Off Ver
    Office 365
    Posts
    6

    Rename file with saveas using string variables in VBA

    Hello,

    1. I need to know how to use save as to save and rename a file on my desktop using string variables. I want the name of the file to be MerchantName (a string variable, whose name is taken from a cell in the excel document) and MerchantDate (a string variable that will be the prior month of this year; with only month and year, no day; so it would be 2/15 for example). These excel files are being stored in a folder and I need to differentiate them by Merchant name and Month of sale.

    I tried to use this code: ActiveWorkbook.SaveAs "MyFile.xls" and converted it to: Activeworkbook.SaveAs MerchantName & MerchantDate & ".xls" but it is not working. I need the correct syntax here....

    2. I am creating this for my business, so it will be saved as a PDF file on different computers with different users. I see in the code when I save the file using a Macro that the following code appears.

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\Jeremiah\Desktop\Master.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    True

    If the user changes (from Jeremiah) to another username, will the code run incorrectly? How do I create an ambiguous name in the code? I may be able to cut it down to be run on only one computer with one user; but in that case I would need to change the: "C:\Users\Jeremiah\Desktop\Master.pdf" to "C:\Users\"NAME OF USER"\Desktop\Master.pdf". Correct?

    Please let me know. Thank you,

    Jeremy
    Last edited by jyfuller; 03-28-2015 at 06:06 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Attachments : Save and Rename using Sublect string or File name string
    By checksamir in forum Outlook Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2014, 01:13 AM
  2. Excel VBA find and replace string in non text file and rename file
    By razzack in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2013, 02:43 PM
  3. [SOLVED] SaveAs does not work with variables for Path and Filename?
    By steveJC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2012, 04:55 AM
  4. Syntax for SAVEAS code using variables for FileFormat and file suffix
    By vcchin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-2010, 11:48 PM
  5. string variables in file names
    By dr chuck in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2006, 03:00 PM

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