当前位置: 代码迷 >> Office >> openoffice -轮换文本的宏
  详细解决方案

openoffice -轮换文本的宏

热度:7426   发布时间:2013-02-26 00:00:00.0
openoffice --替换文本的宏
Sub Main
    Dim mBritishWords(5) As String
    Dim mUSWords(5) As String
    Dim n As Long
    Dim oDocument As Object
    Dim oReplace As Object
    mBritishWords() = Array("colour", "neighbour", "centre", _
    "behaviour", "metre", "through")
    mUSWords() = Array("color", "neighbor", "center", _
    "behavior", "meter", "thru")
    oDocument = ThisComponent
    oReplace = oDocument.createReplaceDescriptor
    For n = lbound(mBritishWords()) To ubound(mBritishWords())
    oReplace.SearchString = mBritishWords(n)
    oReplace.ReplaceString = mUSWords(n)
    oDocument.replaceAll(oReplace)
    Next n

End Sub