如何使用VBA在MS Word的标签基础上获得单独的字符串



我有一个字符串,我想在word的基础上拆分它。

字符串:

 Your meaning <b>is unclear here</b>: please revise.

我想在<b>标签的基础上分离字符串的数据

所以结果会是

Array[0] = "Your meaning ";
Array[1] = "is unclear here";
Array[2] = ": please revise.";

请建议。

你可以这样做:

Option Explicit
Sub Remove()
    Dim str_note    As String
    Dim str_arr()   As String
    Dim str_arr2()  As String
    Dim l_counter   As Long
    Dim l_counter2  As Long
    
    str_note = "Your meaning <b>is unclear here</b>: please revise."
    
    str_note = Replace(str_note, ">", "<")
    
    Debug.Print str_note
    str_arr = Split(str_note, "<")
    
    For l_counter = 0 To UBound(str_arr)
        If l_counter Mod 2 = 0 Then
            If l_counter <> 0 Then l_counter2 = l_counter2 + 1
            ReDim Preserve str_arr2(l_counter2)
            str_arr2(l_counter2) = str_arr(l_counter)
        End If
    Next l_counter
    
End Sub

str_arr2是答案

最新更新