How does one obtain the [search]”Range of a field”[/search[?
I thought it would be simple, it appears not to be.
I can loop through the Fields collection, starting at the end and working my way towards the front, identifying fields to be replace, selecting the field and replacing the selection, but I feel I ought to be able to identify the Range of the field (“Ranges good; Selection bad“) and replace that range’s text.
In the little sample below, not one of the four commented statements will compile syntax free. I’m mightily puzzled.
Sub FieldRange() Dim rng As Range ' Set rng = ActiveDocument.Fields(1).Range ' Set rng = ActiveDocument.Fields(1).Code.Range ' Set rng = ActiveDocument.Fields(1).Data.Range ' Set rng = ActiveDocument.Fields(1).Result.Range rng.Text = "new text" End Sub