Phil Smith
08-31-2014, 11:13 AM
Hi everyone.
I am currently trying Office 365 after using Word 2010.
Whilst I have dabbled in Excel VBA and can just about survive with some occasional help, I have absolutely no knowledge of Word VBA, so have come to plead my case for assistance here!
I have a document that changes twice or more a year which consists of a changing number of pages each time.
I am wondering if it is possible to use VBA to search the document to find the following text and then highlight that text in a given colour:
"67-" plus one unknown character - to be highlighted red
"68-" plus one unknown character - to be highlighted red
"165-" plus one unknown character - to be highlighted yellow
"168-" plus one unknown character - to be highlighted yellow
"172-" plus one unknown character - to be highlighted yellow
The unknown character will either be a 2,3,4,5,6,7,8 or 9
There will also be the occasional piece of text:
"Shunt Class 67, 172, 168 & 165" where I would like the "67" to be highlighted red and the "172", "168" & "165" highlighted yellow, but NOT the commas.
At some point, the last piece of text will also have "68" added to it, but I do not know where in relation to the text as it stands now. I would hazard a guess that if someone can come up with the VBA code to solve this problem for me, from reading the code, I might be able to change it to accommodate the extra text?
The quote marks are not used in the document. They are used here to delineate the actual text that needs to be searched for, from the text of my question.
Thanks in advance for your assistance!
Phil
I am currently trying Office 365 after using Word 2010.
Whilst I have dabbled in Excel VBA and can just about survive with some occasional help, I have absolutely no knowledge of Word VBA, so have come to plead my case for assistance here!
I have a document that changes twice or more a year which consists of a changing number of pages each time.
I am wondering if it is possible to use VBA to search the document to find the following text and then highlight that text in a given colour:
"67-" plus one unknown character - to be highlighted red
"68-" plus one unknown character - to be highlighted red
"165-" plus one unknown character - to be highlighted yellow
"168-" plus one unknown character - to be highlighted yellow
"172-" plus one unknown character - to be highlighted yellow
The unknown character will either be a 2,3,4,5,6,7,8 or 9
There will also be the occasional piece of text:
"Shunt Class 67, 172, 168 & 165" where I would like the "67" to be highlighted red and the "172", "168" & "165" highlighted yellow, but NOT the commas.
At some point, the last piece of text will also have "68" added to it, but I do not know where in relation to the text as it stands now. I would hazard a guess that if someone can come up with the VBA code to solve this problem for me, from reading the code, I might be able to change it to accommodate the extra text?
The quote marks are not used in the document. They are used here to delineate the actual text that needs to be searched for, from the text of my question.
Thanks in advance for your assistance!
Phil