Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-11-2014, 01:42 PM
rsrasc rsrasc is offline Find/Replace Wildcard Needed-Bold & Highlight Windows 7 64bit Find/Replace Wildcard Needed-Bold & Highlight Office 2010 64bit
Competent Performer
Find/Replace Wildcard Needed-Bold & Highlight
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Find/Replace Wildcard Needed-Bold & Highlight

I have the following text and need wildcard to bold and highlight text in yellow.




Answer: A
Answer: B
Answer: C
Answer: D

Thanks!
Reply With Quote
  #2  
Old 11-11-2014, 02:04 PM
macropod's Avatar
macropod macropod is offline Find/Replace Wildcard Needed-Bold & Highlight Windows 7 64bit Find/Replace Wildcard Needed-Bold & Highlight Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I think it's about time you started to apply the techniques the numerous examples you've been given so far and to spend some time learning how to use these Word tools. We're not here to spoon-feed or simply provide a free coding service.

Invest some effort of your own and, if you get stuck, show what you've tried and where you're stuck and we'll provide some guidance.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-11-2014, 03:07 PM
rsrasc rsrasc is offline Find/Replace Wildcard Needed-Bold & Highlight Windows 7 64bit Find/Replace Wildcard Needed-Bold & Highlight Office 2010 64bit
Competent Performer
Find/Replace Wildcard Needed-Bold & Highlight
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Good point, and I agreed. Not trying to get "free" advise without me doing my homework or putting a good effort. I do.

Before posting anything, I spent a good amount of hours searching the net and your site for answers.


Unfortunately, I don't have the necessary skills to come out sometimes with a workable code or solution.

Yesterday, you gave me a workable find/replace code; I try to modify it for something else--spent more than two hours trying to find a solution but couldn't do it.

Anyway, please accept my apologies, and as always I thank you for your valuable cooperation.

Here is a sample code I found on the web so I can bold what I want. Still working on the color issue.

Sincerely


PHP Code:
Sub BoldText()
'
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .Text = "Answer: A"
    .Replacement.Text = ""
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    .Text = "Answer: B"
    .Replacement.Text = ""
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    .Text = "Answer: C"
    .Replacement.Text = ""
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    .Text = "Answer: D"
    .Replacement.Text = ""
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWholeWord = True
    .Execute Replace:=wdReplaceAll
   End With
End With
Application.ScreenUpdating = True
End Sub 
Reply With Quote
  #4  
Old 11-11-2014, 03:55 PM
macropod's Avatar
macropod macropod is offline Find/Replace Wildcard Needed-Bold & Highlight Windows 7 64bit Find/Replace Wildcard Needed-Bold & Highlight Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by rsrasc View Post
Yesterday, you gave me a workable find/replace code; I try to modify it for something else--spent more than two hours trying to find a solution but couldn't do it.
But, as I said in my reply to https://www.msofficeforums.com/word-...html#post73220, all you needed to do was to copy the expressions into a macro coded the same as the previous one I had given you. Thus:
Code:
Sub AnswerLetterChange()
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Text = "<([A-D]):"
  .Replacement.Text = "\1."
  .Execute Replace:=wdReplaceAll
End With
End Sub
might become:
Code:
Sub Demo1()
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Text = "([A-Z]).*[Aa]nswer*( is[ in]{1,3}correct.)"
  .Replacement.Text = "Answer (\1)\2"
  .Execute Replace:=wdReplaceAll
End With
End Sub
Similarly, for the problem here: https://www.msofficeforums.com/word-...rd-needed.html, you might use:
Code:
Sub Demo2()
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Text = "(Answer )([A-Z])"
  .Replacement.Text = "\1(\2)"
  .Execute Replace:=wdReplaceAll
End With
End Sub
As for your current problem, I see no indication you've even tried to use a wildcard expression. With a modicum of reading of the documentation on wildcard usage (e.g. http://office.microsoft.com/en-au/he...001087305.aspx, http://www.gmayor.com/replace_using_wildcards.htm) it would quickly become apparent how easy it is to adapt one of those examples to your current needs.

As for applying the bold and highlight, if you use the macro recorder to capture a Find/Replace using those parameters, it will provide all the bits of code you need. Granted, it can be made more efficient, but all the font/highlight attributes will be there.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/Replace Wildcard Needed-Bold &amp; Highlight New Find/Replace Wildcard Needed rsrasc Word VBA 2 11-11-2014 09:46 AM
Find/Replace Wildcard Needed-Bold &amp; Highlight Wildcard Find and Replace Ulodesk Word 1 06-23-2014 10:26 AM
Wildcard Find/Replace deletes extra character Cosmo Word 1 06-20-2014 08:49 AM
Find/Replace Wildcard Needed-Bold &amp; Highlight Need help using WildCard Find & Replace Cayce Word 1 06-09-2014 04:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft