Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS WORD Macro: Replace "^pnot bold^p" instances and multiple strings

Status
Not open for further replies.

MarkRivera

Technical User
Jan 7, 2010
1
US
Greetings,

Am really stuck…

-Context: Working in WORD 2003. Folks bolded response options in documents rather than using a checkbox or other means. I am trying to extract the chosen responses.

-The text strings of interest appear on rows by themselves (preceded and followed by hard returns)

-Since "unchosen" response options are not bolded, I am trying to delete unbolded instances. This is the main goal.

-Will also appreciate thoughts on how to list multiple text strings on the "Text =" line of the macro.

-I have used the manual replace function (More?Format?Font?Not Bold) while running the macro recorder but the resulting macro does not seem to distinguish bold from "not bold".

Many thanks,

Mark
 
There is an error in the macro recorder (fixed in 2007) that it does not record format details for Find operations.

Add this line:
Code:
Selection.Find.Font.Bold = False
after this one:
Code:
Selection.Find.ClearFormatting

You can only look for one 'Text' item at a time. You may be able to define a wildcard pattern, depending on what you want; otherwise you need to code a loop round multiple operations using an array of terms one at a time.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
If they manually added bold formatting, all you need to do is SelectAll (Ctrl+A) and Reset Character (Ctrl+Spacebar).


Regards: Terry
 
Isn't the OP trying to delete text if it is bolded?

--Lilliabeth
 
I should have read it better. I thought the op wanted to remove the 'bold', not the text.

My thought would be to use Search and Replace to find BOLD strings, replace with nothing and run it manually so as to choose whether to replace or not. But it depends on the number of instances of wanted/unwanted bold sentences that need keeping/removing.



Regards: Terry
 
MarkRivera said:
-Since "unchosen" response options are not bolded, I am trying to delete unbolded instances. This is the main goal.

Actually, the OP is trying to delete the unbolded lines of text.

Hope this helps.

Please help us help you. Read Tek-Tips posting polices before posting.

Canadian members check out Tek-Tips in Canada for socializing, networking, and anything non-technical.
 
If this is an actual VBA question (you are using code), then it should be posted to the VBA forum.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top