MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Exporting multiple sheets to .txt format

  Asked By: Hisham    Date: Oct 06    Category: MS Office    Views: 664

I have a long routine at the end of which there is the following bit
of VBA code to copy CSV formatted data from the routine into a
separate .txt file, in this case named "Gold.txt"

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.NumberFormat = "dd-mm-yy;@"
ActiveWorkbook.SaveAs Filename:= _
"C:\Current Charts\Futurestxt\Gold.txt" _
, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
Application.DisplayAlerts = True

However, this routine will be repeated many times and each time the
output .txt file should have a different name e.g. "Gold.txt",
"Silver.txt", "Copper.txt" etc. Is there a way in which I could make
the code section

ActiveWorkbook.SaveAs Filename:= _
"C:\Current Charts\Futurestxt\Gold.txt"

reference a cell (which at the moment of saving would be in another,
non active workbook) that contains the relevant title for
the output .txt file to avoid having to hard code the title section
numerous times?



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Exporting multiple sheets to .txt format Or get search suggestion and latest updates.