The SaveAs Function

Workbook.SaveAs is the VBA equivalent of saving a text file in Excel by using Office Menu O Save As and choosing a format of Text.

In all versions of Excel prior to Excel 2002, this resulted in a U.S.-formatted text file, with a DMY date order, English month and day names, and so on.

In Excel 2002, the SaveAs method was given the same Local parameter described in the OpenText method in the previous section, resulting in a U.S.-formatted or locally formatted text file, as appropriate. Note that if a cell has been given a locale-specific date format (that is, the number format begins with a locale specifier, such as [$-814] for Norwegian), that formatting will be retained in the text file, regardless of whether it is saved in U.S. or local format:

ActiveWorkbook.SaveAs "Data.Txt", xlText, local:=True

0 0

Post a comment