Hi,
Thanks for that code, excellent :-) I had the same problem and cant believe MS Word still has no solution for this. A simple character mask would suffice. However the code solves the issue and I've made some enhancements to suit my own requirements.
Table 1.1: > Table 1.1
Figure 1.1: > Fig. 1.1
There are two procedures, one to abbreviate and the other to normalize.
Sub AbbreviateCaptions()
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
With Fld
If Left(.Result.Text, 6) = "Figure" And Right(.Result.Text, 1) = ":" Then
.Locked = False
.Update
.Result.Text = Replace(.Result.Text, "Figure", "Fig.", 1, 1)
.Result.Text = Replace(.Result.Text, ":", "", 1, 1)
.Locked = True
End If
If Left(.Result.Text, 5) = "Table" And Right(.Result.Text, 1) = ":" Then
.Locked = False
.Update
.Result.Text = Replace(.Result.Text, ":", "", 1, 1)
.Locked = True
End If
End With
Next
End Sub
Sub NormalizeCaptions()
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
With Fld
If Left(.Result.Text, 4) = "Fig." Then
.Locked = False
.Update
End If
If Left(.Result.Text, 5) = "Table" Then
.Locked = False
.Update
End If
End With
Next
End Sub
|