我周围的一些人在Windows /办公室使用国家本地化。不幸的是,这导致我的宏无法进行简单的数学运算,因为他们使用逗号进行小数位置和pov-ray文件,我编辑,使用逗号仅用于列表分隔符并指向小数点。我知道在Excel中可以使用
覆盖系统小数分隔符With Application.
.DecimalSeparator = "."
.ThousandsSeparator = ","
.UseSystemSeparators = False
End With
然而,在MS Word中没有像DecimalSeparator这样的Application属性。在MS Word中是否有一种在宏运行时覆盖系统分隔符的简单方法?或者我是否需要努力寻找并在阅读povray文件时更换它们?
答案 0 :(得分:2)
我不是很耐心,我用“更难的方式”做到了。我宣布了公共变量
Public strDecimal As String
然后在main sub的开头我用它设置了它的值:
strDecimal = Application.International(wdDecimalSeparator)
然后在源代码中我替换了所有的读入内容,如
CDbl(strShort(5))
带
CDbl(Replace(strShort(5), ".", strDecimal))
和所有的写作
Selection.TypeText Text:=CStr(Int(1000 * bondRadius) / 1000)
带
Selection.TypeText Text:=CStr(Replace(Int(1000 * bondRadius) / 1000, strDecimal, "."))
它不像覆盖系统设置那么优雅,但它花了我不多的时间,它对我有用。如果有人能看到理由,为什么它有时会失败,请留下一些评论。
我会从barrowc的评论(thanx)中获取信息,看看它是只读还是读写值。
答案 1 :(得分:-1)
sub ReplaceCommabetweenDigits(sData as String)
sData = Replace(sData, "0,0", "0.0")
sData = Replace(sData, "0,1", "0.1")
sData = Replace(sData, "0,2", "0.2")
sData = Replace(sData, "0,3", "0.3")
sData = Replace(sData, "0,4", "0.4")
sData = Replace(sData, "0,5", "0.5")
sData = Replace(sData, "0,6", "0.6")
sData = Replace(sData, "0,7", "0.7")
sData = Replace(sData, "0,8", "0.8")
sData = Replace(sData, "0,9", "0.9")
sData = Replace(sData, "1,0", "1.0")
sData = Replace(sData, "1,1", "1.1")
sData = Replace(sData, "1,2", "1.2")
sData = Replace(sData, "1,3", "1.3")
sData = Replace(sData, "1,4", "1.4")
sData = Replace(sData, "1,5", "1.5")
sData = Replace(sData, "1,6", "1.6")
sData = Replace(sData, "1,7", "1.7")
sData = Replace(sData, "1,8", "1.8")
sData = Replace(sData, "1,9", "1.9")
sData = Replace(sData, "2,0", "2.0")
sData = Replace(sData, "2,1", "2.1")
sData = Replace(sData, "2,2", "2.2")
sData = Replace(sData, "2,3", "2.3")
sData = Replace(sData, "2,4", "2.4")
sData = Replace(sData, "2,5", "2.5")
sData = Replace(sData, "2,6", "2.6")
sData = Replace(sData, "2,7", "2.7")
sData = Replace(sData, "2,8", "2.8")
sData = Replace(sData, "2,9", "2.9")
sData = Replace(sData, "3,0", "3.0")
sData = Replace(sData, "3,1", "3.1")
sData = Replace(sData, "3,2", "3.2")
sData = Replace(sData, "3,3", "3.3")
sData = Replace(sData, "3,4", "3.4")
sData = Replace(sData, "3,5", "3.5")
sData = Replace(sData, "3,6", "3.6")
sData = Replace(sData, "3,7", "3.7")
sData = Replace(sData, "3,8", "3.8")
sData = Replace(sData, "3,9", "3.9")
sData = Replace(sData, "4,0", "4.0")
sData = Replace(sData, "4,1", "4.1")
sData = Replace(sData, "4,2", "4.2")
sData = Replace(sData, "4,3", "4.3")
sData = Replace(sData, "4,4", "4.4")
sData = Replace(sData, "4,5", "4.5")
sData = Replace(sData, "4,6", "4.6")
sData = Replace(sData, "4,7", "4.7")
sData = Replace(sData, "4,8", "4.8")
sData = Replace(sData, "4,9", "4.9")
sData = Replace(sData, "5,0", "5.0")
sData = Replace(sData, "5,1", "5.1")
sData = Replace(sData, "5,2", "5.2")
sData = Replace(sData, "5,3", "5.3")
sData = Replace(sData, "5,4", "5.4")
sData = Replace(sData, "5,5", "5.5")
sData = Replace(sData, "5,6", "5.6")
sData = Replace(sData, "5,7", "5.7")
sData = Replace(sData, "5,8", "5.8")
sData = Replace(sData, "5,9", "5.9")
sData = Replace(sData, "6,0", "6.0")
sData = Replace(sData, "6,1", "6.1")
sData = Replace(sData, "6,2", "6.2")
sData = Replace(sData, "6,3", "6.3")
sData = Replace(sData, "6,4", "6.4")
sData = Replace(sData, "6,5", "6.5")
sData = Replace(sData, "6,6", "6.6")
sData = Replace(sData, "6,7", "6.7")
sData = Replace(sData, "6,8", "6.8")
sData = Replace(sData, "6,9", "6.9")
sData = Replace(sData, "7,0", "7.0")
sData = Replace(sData, "7,1", "7.1")
sData = Replace(sData, "7,2", "7.2")
sData = Replace(sData, "7,3", "7.3")
sData = Replace(sData, "7,4", "7.4")
sData = Replace(sData, "7,5", "7.5")
sData = Replace(sData, "7,6", "7.6")
sData = Replace(sData, "7,7", "7.7")
sData = Replace(sData, "7,8", "7.8")
sData = Replace(sData, "7,9", "7.9")
sData = Replace(sData, "8,0", "8.0")
sData = Replace(sData, "8,1", "8.1")
sData = Replace(sData, "8,2", "8.2")
sData = Replace(sData, "8,3", "8.3")
sData = Replace(sData, "8,4", "8.4")
sData = Replace(sData, "8,5", "8.5")
sData = Replace(sData, "8,6", "8.6")
sData = Replace(sData, "8,7", "8.7")
sData = Replace(sData, "8,8", "8.8")
sData = Replace(sData, "8,9", "8.9")
sData = Replace(sData, "8,0", "8.0")
sData = Replace(sData, "9,1", "9.1")
sData = Replace(sData, "9,2", "9.2")
sData = Replace(sData, "9,3", "9.3")
sData = Replace(sData, "9,4", "9.4")
sData = Replace(sData, "9,5", "9.5")
sData = Replace(sData, "9,6", "9.6")
sData = Replace(sData, "9,7", "9.7")
sData = Replace(sData, "9,8", "9.8")
sData = Replace(sData, "9,9", "9.9")
End sub