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 02:45 PM.
Something like:
ActiveWorkbook.SaveAs Filename:= _ "C:\Users\user\Documents\Emails\5Milla\Full Email File_1.csv_Pieces\" & _ Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 3) & "txt", _ FileFormat:=xlText, CreateBackup:=False
Please use Code Tags next time, thanks.
Regards, TMS
Hello James,
This should do it...
Dim n As Long n = InStrRev(ActiveWorkbook.Name, ".") ActiveWorkbook.SaveAs Filename:= _ "C:\Users\user\Documents\Emails\5Milla\Full Email File_1.csv_Pieces\" _ & Left(ActiveWorkbook.Name, n) & "txt" _ , FileFormat:=xlText, CreateBackup:=False
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 Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thank you!
or use the builtin VBA facilities:
sub snb() ActiveWorkbook.SaveAs "C:\Users\user\Documents\Emails\5Milla\Full Email File_1.csv_Pieces\" & CreateObject("scripting.filesystemobject").getbasename(ActiveWorkbook.FullName) , xlText End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks