Using VBA to detect which decimal sign the computer is using

前端 未结 6 1405
你的背包
你的背包 2020-11-30 12:54

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

6条回答
  •  一整个雨季
    2020-11-30 13:07

    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
    

提交回复
热议问题