Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
James James is offline
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

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
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   Report Post  
Posted to microsoft.public.word.docmanagement
James James is offline
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   Report Post  
Posted to microsoft.public.word.docmanagement
adre77 adre77 is offline
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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
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



Reply
Thread Tools
Display Modes

Posting Rules

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 11: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 11:55 PM


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

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"