Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to print numbers invariably using dots as decimal symbol?

Hello,

I need to print to a disk file, numbers that are stored in different cells
of a worksheet, by making use of the dot as decimal symbol. I thought of
loading them in variants first and printing from there a formatted string to
the file, using the FORMAT function.

However, format "0.00" will use the decimal symbol as defined in the locale
(Regional Settings), which is the opposite of what I need.

Does someone know if FORMAT can be instructed to invariably use a dot as
decimal symbol?

Thank you.

Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to print numbers invariably using dots as decimal symbol?

Try to override system settings in ToolsOptionsInternational by unchecking
"Use system separators" and entering dot as Decimal separator!

Regards,
Stefi

€˛Stefano Gatto€¯ ezt Ć*rta:

Hello,

I need to print to a disk file, numbers that are stored in different cells
of a worksheet, by making use of the dot as decimal symbol. I thought of
loading them in variants first and printing from there a formatted string to
the file, using the FORMAT function.

However, format "0.00" will use the decimal symbol as defined in the locale
(Regional Settings), which is the opposite of what I need.

Does someone know if FORMAT can be instructed to invariably use a dot as
decimal symbol?

Thank you.

Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to print numbers invariably using dots as decimal symbol?

Dim OldSeparator As String
OldSeparator = Application.DecimalSeparator
Application.DecimalSeparator = "."
...
Application.DecimalSeparator = OldSeparator

Phil Hibbs.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to print numbers invariably using dots as decimal symbol?

Hm, might need some work... how about this...

Dim OldSysDefault As Boolean
Dim OldSeparator As String
OldSysSep = Application.UseSystemSeparators
OldSeparator = Application.DecimalSeparator
Application.UseSystemSeparators = False
Application.DecimalSeparator = "."
...
Application.DecimalSeparator = OldSeparator
Application.UseSystemSeparators = OldSysSep

Phil Hibbs.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to print numbers invariably using dots as decimal symbol?

Thanks Phil and thanks Stefi to suggest me to use this setting that I even
forgot about its existence...

However, I tried it this way and the numbers keep on being printed with
commas, while the system is set up with the Portuguese locale.



This is the code. Let me know if this is what you meant:


Sub test1()
Dim DebitVal As Double

Application.UseSystemSeparators = False
With Application
.DecimalSeparator = "."
.ThousandsSeparator = ""
End With

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\DDT\Test1.txt", True)

DebitVal = Worksheets("JV_CC_Reclass").Cells(8, 10).Value
a.WriteLine (" <Debit" & Format(DebitVal, "0.00") & "</Debit")
a.Close

Application.UseSystemSeparators = True
End Sub

And this is the content of D:\DDT\Test1.txt:

<Debit356,22</Debit



--
Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)


"Phil Hibbs" wrote:

Hm, might need some work... how about this...

Dim OldSysDefault As Boolean
Dim OldSeparator As String
OldSysSep = Application.UseSystemSeparators
OldSeparator = Application.DecimalSeparator
Application.UseSystemSeparators = False
Application.DecimalSeparator = "."
...
Application.DecimalSeparator = OldSeparator
Application.UseSystemSeparators = OldSysSep

Phil Hibbs.
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to print numbers invariably using dots as decimal symbol?

Looks like the Format() function does not take care of Excel's decimal
separator, but always refers to system's one.
--
Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)


"Stefano Gatto" wrote:

Thanks Phil and thanks Stefi to suggest me to use this setting that I even
forgot about its existence...

However, I tried it this way and the numbers keep on being printed with
commas, while the system is set up with the Portuguese locale.



This is the code. Let me know if this is what you meant:


Sub test1()
Dim DebitVal As Double

Application.UseSystemSeparators = False
With Application
.DecimalSeparator = "."
.ThousandsSeparator = ""
End With

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\DDT\Test1.txt", True)

DebitVal = Worksheets("JV_CC_Reclass").Cells(8, 10).Value
a.WriteLine (" <Debit" & Format(DebitVal, "0.00") & "</Debit")
a.Close

Application.UseSystemSeparators = True
End Sub

And this is the content of D:\DDT\Test1.txt:

<Debit356,22</Debit



--
Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)


"Phil Hibbs" wrote:

Hm, might need some work... how about this...

Dim OldSysDefault As Boolean
Dim OldSeparator As String
OldSysSep = Application.UseSystemSeparators
OldSeparator = Application.DecimalSeparator
Application.UseSystemSeparators = False
Application.DecimalSeparator = "."
...
Application.DecimalSeparator = OldSeparator
Application.UseSystemSeparators = OldSysSep

Phil Hibbs.
.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to print numbers invariably using dots as decimal symbol?

However, I tried it this way and the numbers keep on being printed with
commas, while the system is set up with the Portuguese locale.


Hm, it looks like the VBA Format function always uses your Windows
locale settings, and not the Excel Application settings. Could you
just write out the Cell.Text value?

Phil Hibbs.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to print numbers invariably using dots as decimal symbol?

Hm, it looks like the VBA Format function always uses your Windows
locale settings, and not the Excel Application settings. Could you
just write out the Cell.Text value?


It just occurred to me that I should warn you that the Cell.Text value
is not always reliable. If the column is too narrow, then a cell value
of 1.999 will write out as "2". I see that you want a specific format
"0.00" so that might not be any good.

Cell.FormulaLocal might work, but that will write out the formula if
your cell is calculated.

Phil Hibbs.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to print numbers invariably using dots as decimal symbol?

1. Store the Excel Format setting
2. Set the Excel Format settings to what you want
3. Store the Cell Format and ColumnWidth
4, Set the Cell Number Format to "0.00"
5. AutoFit the Column
6. Write out the Text value of the Cell
7. Set the Excel Format, Cell Format, and Column Width back to how
they were

Sub test1()
Dim DebitVal As Double
Dim OldCellFormat As String
Dim OldWidth As Variant

Application.UseSystemSeparators = False
With Application
.DecimalSeparator = "."
.ThousandsSeparator = ""
End With

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\DDT\Test1.txt", True)

OldCellFormat = Worksheets("JV_CC_Reclass").Cells(8,
10).NumberFormat
Worksheets("JV_CC_Reclass").Cells(8, 10).NumberFormat = "0.00"
OldWidth = Worksheets("JV_CC_Reclass").Cells(8, 10).ColumnWidth
Worksheets("JV_CC_Reclass").Cells(8, 10).EntireColumn.AutoFit

DebitVal = Worksheets("JV_CC_Reclass").Cells(8, 10).Text
a.WriteLine (" <Debit" & Format(DebitVal, "0.00") & "</Debit")
a.Close

Application.UseSystemSeparators = True
Worksheets("JV_CC_Reclass").Cells(8, 10).ColumnWidth = OldWidth
Worksheets("JV_CC_Reclass").Cells(8, 10).NumberFormat =
OldCellFormat
End Sub


You don't have to restore everything after if you don't want to, but I
like to be careful not to mess with things.

Phil Hibbs.
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to print numbers invariably using dots as decimal symbol?

Looks like I can. Thank you very much I did not know this function, I guess
it's new.
--
Stefano Gatto
Have no fear of perfection - you''ll never reach it (Salvador Dali)


"Phil Hibbs" wrote:

However, I tried it this way and the numbers keep on being printed with
commas, while the system is set up with the Portuguese locale.


Hm, it looks like the VBA Format function always uses your Windows
locale settings, and not the Excel Application settings. Could you
just write out the Cell.Text value?

Phil Hibbs.
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to print numbers with dots, regardless of locale Stefano Gatto Excel Programming 8 November 5th 09 02:14 PM
Leading dots...trailing dots Josh O. Excel Discussion (Misc queries) 2 January 31st 08 06:22 PM
Decimal Symbol dawson Excel Programming 6 June 25th 07 06:30 PM
Combobox changes the decimal commas to dots - How to prevent it? Erkka Excel Discussion (Misc queries) 2 February 23rd 07 08:20 AM
Change Dots into Commas as Decimal Divider xenia Excel Discussion (Misc queries) 2 August 8th 05 09:48 AM


All times are GMT +1. The time now is 08:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"