View Single Post
 
Old 04-20-2018, 05:39 AM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Thanks for the response. I'm attaching a demo file with a function 'tetingRegEx'.

For the purposes of this test, I have simplified the regular expression to a simple text pattern, but the one I will be using is much more complicated. This doesn't affect the purpose of this test.

Running the function should highlight every instance of 'Lorem' within the document. There are 2 fields (a 'CreateDate' field, and a text form field) after the second paragraph. In the paragraphs after these fields, the text highlighted is not the found text.

I figured it was due to a discrepancy between the Field.code ( CREATEDATE \@ "M/d/yyyy" \* MERGEFORMAT ) vs Field.result (4/2/2018), but I don't see any correlation between those numbers. e.g. the date field code is 43 characters, the result is 8 characters. But it seems to offset the found range by 46 characters.

If I could find out how to calculate the offset (46 for the date) from each field, then I could loop through all fields that preceed the found text and adjust the position.
Attached Files
File Type: docm TestingRegex.docm (19.7 KB, 11 views)
Reply With Quote