A family of Microsoft word processing software products for creating web, email, and print documents.
Hi, Doug.
I'm reluctant to share my code for personal reasons, as the code might eventually be a marketable product, if I can get around the problems I have. (I'm unlikely to actually try and market the code, but I want to retain the possibility.) In addition, the code in question is probably several hundred, if not a thousand, lines in length, but my question relates to only a small portion of the code.
This is actually not my first attempt to deal with the problem I have been having, but other posts to the forum have not yielded answers that worked. I keep trying to solve my problem in different ways, only to find that VBA in Microsoft Word has problems with every approach I have tried.
To summarize the problem, I am attempting to perform a search and replace on text in a document, where the text meets a pattern that can be expressed as a regular expression (or multiple individual search strings with wildcards using Find and Replace), but the substitute text varies at each instance and does not depend on the text in the original string (that is, the substitute text is not simply a rearrangement of text). If there is a comment buried in the document, the comment can throw off the search and replacement (however performed), preventing the macro from operating correctly. ^a as a wildcard search parameter in a VBA Find and Replace sort of works, but not consistently; the VBscript RegExp object removes comments (or, I think, any formatting for that matter) when using the Replace method); and the VBScript RegExp object does not correctly identify where in the text the located strings are when using the Execute method.
I am open to other ideas how to proceed.
Thanks,
Ariel