+ Reply to Thread
Results 1 to 5 of 5

VBA script- save file with current filename

  1. #1
    Registered User
    Join Date
    10-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    VBA script- save file with current filename

    Hi guys, I'm sure this is an easy one but I couldn't find anything from searching.

    I want to save the current .csv file and a .txt with the same name. The file type is not problem but I can't find out how to specify the filename as the current filename.

    Thanks in advance for any help,
    James


    EDIT
    This is what I have now but I want "Filename.txt" to be the current workbook filename.
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Users\user\Documents\Emails\5Milla\Full Email File_1.csv_Pieces\Filename.txt" _
    , FileFormat:=xlText, CreateBackup:=False
    Last edited by -James_; 01-06-2012 at 03:45 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    30,446

    Re: VBA script- save file with current filename

    Something like:

    Please Login or Register  to view this content.

    Please use Code Tags next time, thanks.


    Regards, TMS
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA script- save file with current filename

    Hello James,

    This should do it...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    10-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA script- save file with current filename

    Thank you!

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,646

    Re: VBA script- save file with current filename

    or use the builtin VBA facilities:
    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