如果有人需要這個問題的答案..這裏是我做過什麼,
Selection.MoveUp Unit:=wdParagraph, Count:=2000
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("\[", "\] ", " \*")
vReplText = Array("", "", "")
With Selection
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.MatchWholeWord = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.MatchWildcards = True
.Format = True
.MatchCase = True
For i = 0 To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute Replace:=wdReplaceAll
Next i
.Text = "[0-9]{1,}"
.Replacement.Text = "^&"
.Replacement.Font.Superscript = True
.Execute Replace:=wdReplaceAll, MatchWildcards:=True
End With
End With
MsgBox "Numbers has finshed , calling double1"
Call Numbers1
這將引發所有的數字變成標然後調用子Numbers1
Sub Numbers1()
Dim chr As Range
Dim firstChar As Word.Range
Dim test As Integer
test = 0
Dim firstAlphabet As Range
Selection.SetRange Start:=0, End:=100000
Set firstAlphabet = Selection.Range
For i = 2 To 1600
test = test + 2
Set firstChar = Selection.Characters(test)
If IsNumeric(firstChar.Text) Then firstChar.Font.Subscript = True
On Error Resume Next
Next i
End Sub
這將把所有的數字交替換成下標和上標...... 這段代碼可以明顯優化,,,目前執行給定工作需要很長時間,,,但是在整天搜索工作方法後,這是該工程
希望這將有助於將有人談到誰找到這個:)
'測試=真 昏暗CHR作爲範圍 對於每個CHR在ActiveDocument.Range.Characters 如果則IsNumeric(唯一chr.Text)和test = True然後chr.Font.Subscript = True並且test = False 如果IsNumeric(chr.Text)和t EST = false,那麼chr.Font.Superscript = True和測試=真 接下來chr'我試過這樣......但它不會工作,,請在此 –
幫助'和'是一個邏輯運算符,而不是東西來連接線。像這樣使用'And'將導致VBA將這兩個語句評估爲布爾值,而不是設置屬性。 – arcadeprecinct
您能否爲我構建這個,我已經嘗試過了,但是,這對我來說可能會有所幫助 –