更新时间:2023-10-05 18:53:22
这是一项微不足道的任务.一个人想知道您是否甚至尝试过修改现有代码.如果对它应用合适的项目符号格式,则可以使用现有的内容控件完成全部操作.例如:
This is a trivial undertaking. One wonders whether you even tried to modify your existing code. The whole lot could be done with your existing content control if you apply a suitable bullet format to it. For example:
Private Sub Test()
Dim SelectedTexts As String
Dim index As Long
For index = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(index) Then
SelectedTexts = SelectedTexts & ListBox1.List(index) & ";" & vbCr
End If
Next
SelectedTexts = Mid(SelectedTexts, 1, Len(SelectedTexts) - 2) & "."
index = InStrRev(SelectedTexts, vbCr)
If index > 0 Then SelectedTexts = Left(SelectedTexts, index - 1) & " and " & Right(SelectedTexts, Len(SelectedTexts) - index + 1)
ActiveDocument.SelectContentControlsByTitle("test").Item(1).Range.Text = SelectedTexts
End Sub