Sub chk_shangbiao() Dim flag As Boolean Dim filename As String filename = ActiveDocument.Name Dim newdoc As Document Set newdoc = Documents.Add flag = True Documents(filename).Activate Selection.HomeKey Unit:=wdStory Do Dim mystr As Range Selection.Find.ClearFormatting
Selection.Find.Execute Set mystr = Selection.Range If Selection.Find.Found = True Then ' MsgBox mystr.Text If Left(mystr.Text, 1) = " " Or Right(mystr.Text, 1) = " " Then MsgBox mystr.Text newdoc.Content = newdoc.Content & mystr.Text & Chr(13) & Chr(10) End If Else flag = False End If Loop While flag newdoc.Activate newdoc.SaveAs ("d:\check_shangbiao.doc") End Sub这段代码主要是为了检查上标前后是否有被标记了上标的空格 和两个上标之间是否有正常空格
Dim flag As Boolean
Dim filename As String
filename = ActiveDocument.Name
Dim newdoc As Document
Set newdoc = Documents.Add
flag = True
Documents(filename).Activate
Selection.HomeKey Unit:=wdStory
Do
Dim mystr As Range
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindContinue
.Font.Superscript = True
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Set mystr = Selection.Range
If Selection.Find.Found = True Then
' MsgBox mystr.Text
If Left(mystr.Text, 1) = " " Or Right(mystr.Text, 1) = " " Then
MsgBox mystr.Text
newdoc.Content = newdoc.Content & mystr.Text & Chr(13) & Chr(10)
End If
Else
flag = False
End If
Loop While flag
newdoc.Activate
newdoc.SaveAs ("d:\check_shangbiao.doc")
End Sub这段代码主要是为了检查上标前后是否有被标记了上标的空格
和两个上标之间是否有正常空格
用Range或Selection对象的Move方法移到下一个字符,获取当前字符的Font属性中的Superscript属性?