A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

applying macro to a selected text only



 
 
Thread Tools Display Modes
  #1  
Old November 8th 08, 11:06 AM posted to microsoft.public.word.docmanagement
James
external usenet poster
 
Posts: 113
Default applying macro to a selected text only

Hi

Is there a way to apply a macro to a selected text only, whether the text is
a word, phrase, sentence, or paragraph? The macro is rather simple, a
recorded macro that removes vowels:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[aeiouAEIOU]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Ads
  #2  
Old November 8th 08, 12:16 PM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default applying macro to a selected text only

Change
.Wrap = wdFindContinue
to
.Wrap = wdFindStop


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



James wrote:
Hi

Is there a way to apply a macro to a selected text only, whether the
text is a word, phrase, sentence, or paragraph? The macro is rather
simple, a recorded macro that removes vowels:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[aeiouAEIOU]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub



  #3  
Old November 8th 08, 03:21 PM posted to microsoft.public.word.docmanagement
James
external usenet poster
 
Posts: 113
Default applying macro to a selected text only

Great! Thanks a lot.

"Graham Mayor" wrote:

Change
.Wrap = wdFindContinue
to
.Wrap = wdFindStop


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



James wrote:
Hi

Is there a way to apply a macro to a selected text only, whether the
text is a word, phrase, sentence, or paragraph? The macro is rather
simple, a recorded macro that removes vowels:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[aeiouAEIOU]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub




  #4  
Old April 16th 09, 11:01 PM posted to microsoft.public.word.docmanagement
adre77
external usenet poster
 
Posts: 1
Default applying macro to a selected text only

Do you know how can I do this in Excel?
I am trying to create a macro to apply the same border format to a selected
range of cells. No luck so far... Any ideas?

"Graham Mayor" wrote:

Change
.Wrap = wdFindContinue
to
.Wrap = wdFindStop


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



James wrote:
Hi

Is there a way to apply a macro to a selected text only, whether the
text is a word, phrase, sentence, or paragraph? The macro is rather
simple, a recorded macro that removes vowels:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[aeiouAEIOU]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub




  #5  
Old April 17th 09, 06:16 AM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default applying macro to a selected text only

Ask Excel questions in an Excel forum. This one is for Word.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



adre77 wrote:
Do you know how can I do this in Excel?
I am trying to create a macro to apply the same border format to a
selected range of cells. No luck so far... Any ideas?

"Graham Mayor" wrote:

Change
.Wrap = wdFindContinue
to
.Wrap = wdFindStop


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



James wrote:
Hi

Is there a way to apply a macro to a selected text only, whether the
text is a word, phrase, sentence, or paragraph? The macro is rather
simple, a recorded macro that removes vowels:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[aeiouAEIOU]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying hidden text when recording a macro jlfetch Microsoft Word Help 1 October 29th 08 10:07 PM
keyboard shortcuts applying to whole doc, not selected text gus Microsoft Word Help 2 June 22nd 07 08:34 AM
Macro only selected text Greg In Atl Microsoft Word Help 2 April 26th 07 08:30 PM
Applying a background colour to styles for selected text only Denise Freiburger Microsoft Word Help 8 September 1st 06 12:45 AM
Macro: Execute for Selected Text Only Pleonasm Microsoft Word Help 4 November 29th 05 10:55 PM


All times are GMT +1. The time now is 12:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.