PDA

View Full Version : preserve regional settings when saving to xlTextPrinter



crush
11-13-2009, 06:33 PM
wondering if anyone can help with this one.

when i change the regional settings to Norwegian (bokmal) format, and then open my spreadsheet, periods (decimal places) are changed to commas.

i have a function that saves the sheet data to txt file using the following

' Save as a space delimited text file
Application.DisplayAlerts = False ' Suppress over-write file msg
ActiveWorkbook.SaveAs Filename:= _
"c:\temp\mytextfile.txt", _
FileFormat:=xlTextPrinter, _
CreateBackup:=False


when i then view the text file, all the commas are changed to periods? i want to be able to save the contents of the sheet with the commas, just like i see the work sheet.

note. if i manually choose save as and choose the space delimited format, the commas are preserved. the issue only appears when i attempt to do this programmatically.

i've tried searching the forum for similar issues but did not seem to have much luck.

mdmackillop
11-14-2009, 05:41 AM
I would suggest that the commas are for "display" purposes, and that the period is needed for the value. If I were to open a text file with comma decimals in Excel, these would be text, not numerical values. Your Norwegian vesion could cater for this, showing you numbers with comma decimals.

A possible workaround.
Reformat your cells as text, Edit/Replace Periods with Commas and then save as the Text file.