Hi, all. Again, I’m humbled… after all these years, I do not know the most efficient way of doing something that seems so simple.
I want to programmatically insert text immediately preceding a field code, using the Range object. I figured I’d determine the “insertion point” by setting a range variable to the same range as the current Field.Result, then collapsing it. But when I do that and use the Insert method, the text is added to the field results, which of course means that it will go away when the field is next updated. I want it added outside the field, in front of it.
So, my question is, what’s the trick to adding text to a range immediately preceding a field code? Should I not use the field code’s range when I initially use the Set statement for the insertion range? Is there an obscure argument to the InsertAfter method that prevents the text from becoming part of the following field?
Here is a snippit of how I’m currently trying to do it. (The tField variable is the current field, which is part of the document’s Fields collection, accessed with a “For Each” loop.)
Set nRange = tField.Result
nRange.Collapse
nRange.InsertAfter “: ”
Any tips? Tricks? Best Practices?