Onderstaande code zet cijfers om naar superscript, echter niet als dit cijfer geplakt zit aan de tekst. In onderstaande voorbeeld wordt alleen de eerste regel omgezet.
Voorbeeld:
1 QXQXW
2QSXWX
4Kmmk km
8Plldmd
3CVC
Wat gaat er fout?
Voorbeeld:
1 QXQXW
2QSXWX
4Kmmk km
8Plldmd
3CVC
Wat gaat er fout?
Code:
Sub ConvertToSuperscript()
'
' Alle getallen in tekst omzetten naar Superscript
'
'
Dim doc As Document
Dim arrA As Variant, arrW As Variant
Dim i As Long, b As Integer
Set doc = ActiveDocument
arrA = Split(doc.Content, Chr(13))
For i = LBound(arrA) To UBound(arrA)
arrW = Split(arrA(i), " ")
For b = LBound(arrW) To UBound(arrW)
If IsNumeric(arrW(b)) Then
With doc.Content.Find
.ClearFormatting
.Text = arrW(b)
With .Replacement
.ClearFormatting
.Font.Superscript = True
.Font.Subscript = False
End With
.Execute FindText:=arrW(b), ReplaceWith:=arrW(b), Format:=True, Replace:=wdReplaceAll
End With
End If
Next b
Next i
MsgBox "Alle cijfers omgezet naar superscript!", vbOKOnly
End Sub