![]() |
|
|
|
#1
|
|||
|
|||
|
I'm working heavily on contracts and agreements (word 2003). so many terms (words) needs to be bold. to save my time I usually put them between the symbols " " and at the end I search for these symbols and start making them bold one by one.
Is there any code to automate this process i.e.: to search the symbols " " and make the words between them in bold. Is it possible? thanks in advance |
|
#2
|
|||
|
|||
|
This should do it:
Code:
Sub SearchInQuotes()
Dim bWC As Boolean
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.MatchWildcards = True
'find curly
'.Text = "^0147*^0148"
'Find straight
'.Text = "^34*^34"
'Find both
.Text = "[^34^0147]*[^34^0148]"
While .Execute
oRng.Characters(1).Delete
oRng.Characters.Last.Delete
oRng.Font.Bold = True
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
|
|
#3
|
|||
|
|||
|
Dear Greg.
First of all thanks alot. the code only removed the "" characters. If you please; I'd like to keep the "" characters as is and make the text between them (bold) Thanks in advance |
|
#4
|
|||
|
|||
|
Sub SearchInQuotes()
Dim bWC As Boolean Dim oRng As Word.Range Set oRng = ActiveDocument.Range With oRng.Find .MatchWildcards = True 'find curly '.Text = "^0147*^0148" 'Find straight '.Text = "^34*^34" 'Find both .Text = "[^34^0147]*[^34^0148]" While .Execute 'oRng.Characters(1).Delete 'oRng.Characters.Last.Delete oRng.Font.Bold = True oRng.Collapse wdCollapseEnd Wend End With End Sub |
|
#5
|
|||
|
|||
|
Good evening Greg,
It seems my description wasn't clear. Hereunder, a sample to what exactly I was searching for. Thanks for your help As is text To be after VBA code
"Register" abc "Register" abc The overall "revenue" is The overall "revenue" is |
|
#6
|
|||
|
|||
|
This finds text between quotes and bolds the text leaving the quotes unbolded:
Code:
Sub SearchInQuotes() Dim bWC As Boolean Dim oRng As Word.Range Set oRng = ActiveDocument.Range With oRng.Find .MatchWildcards = True 'find curly '.Text = "^0147*^0148" 'Find straight '.Text = "^34*^34" 'Find both .Text = "[^34^0147]*[^34^0148]" While .Execute oRng.MoveStart wdCharacter, 1 oRng.MoveEnd wdCharacter, -1 oRng.Font.Bold = True oRng.Collapse wdCollapseEnd Wend End With End Sub |
|
#7
|
|||
|
|||
|
I tried with the latest code but nothing happens at all in the document.
sorry to disturb you Greg but it's urgent to me. thanks |
|
#8
|
|||
|
|||
|
I'm sorry, I was trying on Arabic text. when I tried the code on English text it works perfect but with Arabic not functioning.
Furthermore, please, how to get the code for the other characters like ?, = , {}? thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaanks |
|
#9
|
|||
|
|||
|
I was trying on Arabic text. when I tried the code on English text it works perfect but with Arabic not functioning.
Furthermore, please, how to get the code for the other characters like ?, = , {}? |
|
#10
|
||||
|
||||
|
Cross-posted, without even acknowledging the prior assistance given here, at: http://www.excelforum.com/word-progr...rd-2013-a.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Replace words within headers in multiple document
|
Carchee | Word VBA | 14 | 12-19-2013 04:36 PM |
Highlight and then replace multiple words
|
redhin | Word VBA | 5 | 03-05-2013 05:42 AM |
Macro to replace few words in the document
|
ubns | Word VBA | 7 | 08-16-2012 10:33 PM |
Find and Replace - symbols
|
clisco | Word | 5 | 01-03-2010 05:57 AM |