Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: saveas Text

Status
Not open for further replies.

baerwurf

Technical User
Mar 3, 2003
2
EU
How can I save a workbook as text document with "," in numbers (not talking about the "," between entries as in CSV formats). I have a xls-list with entries like "0,5", and I get "0.5" after exporting and opening with an text editor. Right now I do
ActiveWorkbook.SaveAs Filename:="C:\temp\Hello.asc", _
FileFormat:=xlText, CreateBackup:=False

If I do save the workbook manually by "save as" ".txt tab deliminated", I finally get my "0,5"... So it only doesn't work by saving it with VBA.
 
You need to change the decimal indicator in Options/International Tab. Skip,
Skip@theofficeexperts.com
 
decimal indicator is on ",", but it doesn't help
Arne
 
If all else fails, it's easy enough to write the text file using sequential file processing in VBA, something like:

open "MyFile.txt" for output as #1
with activesheet.usedrange
for i=1 to .rows
print#1,.cells(i,1);
for j=2 to .columns
print#1,vbTab,.cells(i,j);
next j
print #1
next i
end with
close #1

In the print# statements, you may or may not need to use format(.cells(i,j)) to get the correct (comma) format - you'd have to experiment and see what works.
Rob
[flowerface]
 
In your Control Panel (Start/Control Panel) go to Regional Settings - Number & Currency Tabs Skip,
Skip@theofficeexperts.com
 
Here is your code. This will save it as "0,5"

Code:
ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\Administrator\My Documents\Book1.txt", FileFormat _
        :=xlText, CreateBackup:=False

Let me know if this helps

Xavier ----------------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning."
Rich Cook
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top