Is it possible to use VBA to detect which decimal sign is being used on the computer?
I have a macro script that adds a conditional formatting to an excel sheet. The
My 2 cents here mixing the Excel answers here and the awesome registry trick from Erik A.; but I want to include Word in this game, because I use to automate Word/Outlook a lot:
Function CorrectDecimalSeparator() As String
Dim auxCorrectListSeparator As String
If WordIsOpen Then
CorrectDecimalSeparator= Word.Application.International(wdListSeparator)
ElseIf ExcelIsOpen Then
CorrectDecimalSeparator= Excel.Application.International(xlListSeparator)
Else
auxCorrectListSeparator = CreateObject("WScript.Shell").RegRead("HKCU\Control Panel\International\sDecimal")
End If
End Function
Function WordIsOpen() As Boolean
Dim oWord As Object
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
On Error GoTo 0
WordIsOpen = Not oWord Is Nothing
Set oWord = Nothing
End Function
Function ExcelIsOpen() As Boolean
Dim oExcel As Object
On Error Resume Next
Set oExcel = GetObject(, "Excel.Application")
On Error GoTo 0
ExcelIsOpen = Not oExcel Is Nothing
Set oExcel = Nothing
End Function