Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2011, 10:32 PM
qcom qcom is offline Macro to find text in between two characters and then format selected text? Mac OS X Macro to find text in between two characters and then format selected text? Microsoft Office 2008 for Mac
Novice
Macro to find text in between two characters and then format selected text?
 
Join Date: Apr 2011
Posts: 3
qcom is on a distinguished road
Default Macro to find text in between two characters and then format selected text?

I'm completely new to macros in MS Word, but not entirely new to programming.

I'm looking to select all of the words in my document that begin with a "7" and end with a "pm". They have varying stuff in between such as "7:47pm" and so on.



How would I go about making such a macro in VBA?

Once selected, I would like to change the font size down to 7.

I would imagine this would be super simple macro for those experienced, but I really have no idea where to start.

Any suggestions are appreciated.

Thanks!
Reply With Quote
  #2  
Old 04-23-2011, 11:23 PM
macropod's Avatar
macropod macropod is offline Macro to find text in between two characters and then format selected text? Windows 7 32bit Macro to find text in between two characters and then format selected text? Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi gcom,

If you're wanting to change the whole string to 7pt, use a wildcard Find/Replace, where:
Find = 7:[0-9]{2}pm
Replace = ^&
and the replacement font option is set to 7pt.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-24-2011, 12:36 AM
qcom qcom is offline Macro to find text in between two characters and then format selected text? Mac OS X Macro to find text in between two characters and then format selected text? Microsoft Office 2008 for Mac
Novice
Macro to find text in between two characters and then format selected text?
 
Join Date: Apr 2011
Posts: 3
qcom is on a distinguished road
Default

Thank you so much for helping me with that!

So, how exactly does that work? I understand the "7:" and "pm" obviously, but what is with the "[0-9] and the "{2}"?

The "^&" just replaces with the same content in the find box, right?

Thanks!
Reply With Quote
  #4  
Old 04-24-2011, 02:04 AM
macropod's Avatar
macropod macropod is offline Macro to find text in between two characters and then format selected text? Windows 7 32bit Macro to find text in between two characters and then format selected text? Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 qcom View Post
So, how exactly does that work? I understand the "7:" and "pm" obviously, but what is with the "[0-9] and the "{2}"?

The "^&" just replaces with the same content in the find box, right?
The [0-9] tells Word to find any number from 0-9; the {2} specifies that it must be a 2-digit number.

You're right about the ^&.

Check out Word's Help file for more details on using wildcards.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-19-2015, 11:07 PM
mohsen.amiri mohsen.amiri is offline Macro to find text in between two characters and then format selected text? Windows XP Macro to find text in between two characters and then format selected text? Office 2007
Competent Performer
 
Join Date: Aug 2014
Posts: 221
mohsen.amiri is an unknown quantity at this point
Default

macropod
What is the function of ^? while using it in find dialog (I mean CTRL+F)?
Reply With Quote
  #6  
Old 02-19-2015, 11:23 PM
macropod's Avatar
macropod macropod is offline Macro to find text in between two characters and then format selected text? Windows 7 64bit Macro to find text in between two characters and then format selected text? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

The '^?' combination means 'any character' but is not valid for a wildcard Find. For other control characters you can use in the Find/Replace expression, see: https://support.office.microsoft.com...rs=en-US&ad=US
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find text in between two characters and then format selected text? How to give line numbering to only selected text? garlapati Word 5 04-04-2011 02:05 PM
Macro to find text in between two characters and then format selected text? Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Objective: Automatically export email text,attachment text to DB friendly format SilentLee Outlook 0 11-14-2010 02:45 PM
Selected text and logo in one macro marijke Word VBA 0 08-24-2009 07:01 AM
Select text between characters davers Word 10 05-24-2009 05:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:40 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