2,462
社区成员
发帖
与我相关
我的任务
分享
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
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
这段代码主要是为了检查上标前后是否有被标记了上标的空格
和两个上标之间是否有正常空格