-1

我在 MS word 文件中有一段文本,如下所示:

[[ul]]
•   For the near term, all Cendoc content will be ingested into the NextBook_Cendoc_June2011 database. 
•   You must navigate to and open this database before you can ingest Cendoc XML. 
•   You can locate this database for the first time by selecting the DATABASE option from the blue navigation bar at the top of the screen. Select the “Browse all database/choose a database” option. Select the “NextBook_Cendoc_June2011” link from the menu. 
[[/ul]]

我需要使用 VBA 的输出如下

<list identifier="" list-style="Unordered">
<item identifier=""""><para identifier="">For the near term, all Cendoc content will be ingested into the NextBook_Cendoc_June2011 database.</para></item>
<item identifier=""""><para identifier="">You must navigate to and open this database before you can ingest Cendoc XML.</para></item>
<item identifier=""""><para identifier="">You can locate this database for the first time by selecting the DATABASE option from the blue navigation bar at the top of the screen. Select the “Browse all database/choose a database” option. Select the “NextBook_Cendoc_June2011” link from the menu.</para></item>
</list>

我应该怎么办?

4

1 回答 1

1

Well, I did what I suggested and recorded a search and replace macro for you, and this is what I came up with.

Option Explicit

Sub SearchAndReplace()

    Selection.HomeKey Unit:=wdStory

    With Selection.Find
        .Text = "[[ul]]"
        .Replacement.Text = "<list identifier="""" list-style=""Unordered"">"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll


    With Selection.Find
        .Text = "•   "
        .Replacement.Text = _
            "<item identifier=""""""""><para identifier="""">"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll


    With Selection.Find
        .Text = "[[/ul]]"
        .Replacement.Text = "</list>"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub
于 2013-02-01T12:56:37.707 回答