首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 办公应用 > OFFICE教程 >

openoffice -查寻文本并设置文本字体的宏

2013-02-04 
openoffice --查找文本并设置文本字体的宏Sub MainDim oDocument As ObjectDim oSearch As Object, oResul

openoffice --查找文本并设置文本字体的宏
Sub Main
    Dim oDocument As Object
    Dim oSearch As Object, oResult As Object
    Dim oFound As Object, oFoundCursor As Object
    Dim n As Long
    oDocument = ThisComponent
    oSearch = oDocument.createSearchDescriptor
    'oSearch.SearchString = "the[a-z]"
    oSearch.SearchString = "x"
    oSearch.SearchRegularExpression = TRUE
    oResult = oDocument.findAll(oSearch)
    For n = 0 To oResult.count - 1
    oFound = oResult(n)
    oFoundCursor = oFound.Text.createTextCursorByRange(oFound)
    oFoundCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
    Next n
    'oSearch.SearchString = "all[a-z]"
    oSearch.searchString = "y"
    oFound = oDocument.findFirst(oSearch)
    While NOT IsNull(oFound)
    oFoundCursor = oFound.Text.createTextCursorByRange(oFound)
    oFoundCursor.CharPosture = com.sun.star.awt.FontSlant.ITALIC
    oFound = oDocument.findNext(oFound, oSearch)
    Wend
End Sub

热点排行