PDA

View Full Version : Find 7-character instance throughout document and change its format



CJane
08-03-2012, 05:05 PM
I have a document with dozens of paragraphs that begin with the letters FR followed by 5 numbers, e.g., FR56789. The paragraphs' font is Arial, 12 pt.

I want to go through the document, find every instance of "FR^#^#^#^#^#", and change the font of each instance to Arial Narrow, 10 pt.

I have some coding experience but I am new to VBA. Using the Record Macro capability, I can change the format of the first instance, and by trying to incorporate code from some examples, I've actually been able to change every other instance, but I have no idea why it's every other one!

Rather than sharing my feeble attempts, I'll just throw this cry for help out to you experts.

macropod
08-03-2012, 10:54 PM
Hi CJane,

You could do this with a wildcard Find/Replace, where:
Find = FR[0-9]{5}
Replace = ^&
and you specify the 10pt Arial Narrow font as a replacement parameter. If you only want to replace the 12pt Arial instances, specify that as a Find parameter as well.

You don't really need a macro for this, though the macro recorder will provide the required code if you really want to.

CJane
08-04-2012, 05:50 PM
Paul, thank you for your help! I'm using Rational Publishing Engine to convert a DOORS module into a Word output and I'm doing some fine tuning of the output format with a string of macros that RPE executes after the conversion is complete. Your help allowed me to add the final touch!!! Again, thank you for the help and for responding so quickly.