|
下边的模块已经在附件中
Sub aa()
Dim wrng11, wrng12 As String
Dim str11(), str12(), str13(), str51(), str52(), str53() As String
With ActiveDocument
Selection.HomeKey wdStory '光标加到文首
Selection.Find.ClearFormatting
Selection.Find.Style = .Styles("标题 3")
Selection.Find.Format = True
If Selection.Find.Execute("1.8.1工程措施") Then _
MsgBox "1.8.1工程措施内容" & Chr(13) & "成功获取": wrng11 = Selection.Bookmarks("\headinglevel").Range.Text
str11() = Split(wrng11, Chr(13), , vbTextCompare)
MsgBox UBound(str11)
End With
End Sub
运行后:提示类型不符
但是运行下边这个过程 正常运行 百思不得其解
Sub SplitWords()
Dim wrng11, wrng12 As String
Dim str11(), str12(), str13(), str51(), str52(), str53() As String
With ActiveDocument
Selection.HomeKey wdStory '光标加到文首
Selection.Find.ClearFormatting
Selection.Find.Style = .Styles("标题 3")
Selection.Find.Format = True
If Selection.Find.Execute("1.8.1工程措施") Then _
MsgBox "1.8.1工程措施内容" & Chr(13) & "成功获取": wrng11 = Selection.Bookmarks("\headinglevel").Range.Text
'str11() = Split(wrng11, Chr(13), , vbTextCompare)
' MsgBox UBound(st11)
Dim strText As String
Dim strResult() As String
Dim i As Long
Dim str As String
strText = wrng11
strResult() = Split(strText, Chr(13), , vbTextCompare)
Debug.Print LBound(strResult)
For i = LBound(strResult) To UBound(strResult)
str = str & strResult(i) & vbCrLf
Next i
MsgBox "拆分的单词:" & vbCrLf & str
End With
End Sub
|
|