Search code examples
vbams-word

Using VBA, How to determin the Field's range in Word Document?


I am using the code below to get the field's range. is there a way to get the Field's range without Using the Selection Object?

dim Fld as Field
dim Rng as Range
dim Prev as Range
'... Ommited code ...
set Prev=Selection.Range
fld.Select
set Rng = Selection.Range 'new selection
Prev.Select ' restore previous selection
debug.print Rng.Paragraphs(1).Range.Text

Solution

  • Provided you can find the field you want you can use its Result property to get the range.