在两个名称之间插入分号

时间:2016-07-21 09:32:41

标签: vba word-vba

我是vba的新手。我如何在两个名称之间包含分号。插入分号后,我需要为我使用以下代码应用自定义样式

Public Sub MakeAuthor()
        ApplyParaStyle ActiveDocument.Styles("author"), False
        Application.ScreenRefresh
End Sub 

INPUT

Sam S,1 Manu D,2 Ananthu-krishna D,3 vivek dk,4 sachin Lee,5 
    Alexander won,6 Binoy S,7 brett Lee,8

输出

Sam S,1 Manu D,2; Ananthu-krishna D,3; vivek dk,4; sachin Lee,5; 
    Alexander won,6; Binoy S,7; brett Lee,8

1 个答案:

答案 0 :(得分:1)

循环字符串,当您找到一个数字,后面跟一个空格插入List = "Sam S,1 Manu D,2 Ananthu-krishna D,3 vivek dk,4 sachin Lee,5 " & vbCrLf & _ " Alexander won,6 Binoy S,7 brett Lee,8" Dim i As Long For i = 1 To Len(List) - 1 If Mid$(List, i, 2) Like "# " Then i = i + 1 Mid$(List, i, 1) = ";" End If Next 'if you want a space after ; List = Replace$(List, ";", "; ") Debug.Print List

Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference