Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2014, 11:34 AM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default replace words between two symbols

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
Reply With Quote
  #2  
Old 01-31-2014, 12:49 PM
gmaxey gmaxey is offline replace words between two symbols Windows 7 32bit replace words between two symbols Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 01-31-2014, 01:01 PM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 01-31-2014, 01:16 PM
gmaxey gmaxey is offline replace words between two symbols Windows 7 32bit replace words between two symbols Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 01-31-2014, 02:28 PM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 01-31-2014, 02:31 PM
gmaxey gmaxey is offline replace words between two symbols Windows 7 32bit replace words between two symbols Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 02-01-2014, 01:11 AM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

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
Reply With Quote
  #8  
Old 02-01-2014, 05:06 AM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

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
Reply With Quote
  #9  
Old 02-01-2014, 02:04 PM
capitala capitala is offline replace words between two symbols Windows 7 64bit replace words between two symbols Office 2003
Advanced Beginner
replace words between two symbols
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

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 ?, = , {}?
Reply With Quote
  #10  
Old 02-03-2014, 03:57 AM
macropod's Avatar
macropod macropod is offline replace words between two symbols Windows 7 32bit replace words between two symbols Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
replace words between two symbols Replace words within headers in multiple document Carchee Word VBA 14 12-19-2013 04:36 PM
replace words between two symbols Highlight and then replace multiple words redhin Word VBA 5 03-05-2013 05:42 AM
replace words between two symbols Macro to replace few words in the document ubns Word VBA 7 08-16-2012 10:33 PM
replace words between two symbols Find and Replace - symbols clisco Word 5 01-03-2010 05:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:03 AM.


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