atw: Re: Word macro help

  • From: Iinet <mkofler@xxxxxxxxxxxx>
  • To: "austechwriter@xxxxxxxxxxxxx" <austechwriter@xxxxxxxxxxxxx>
  • Date: Wed, 3 Dec 2014 10:03:22 +1100

Geoff
Try this simpler macro instead.
Simply select range of text and run macro.
Let me know if it does not work.

Sub ReplaceText()
Dim TexttoReplace As String
 
TexttoReplace = Selection
 
TexttoReplace = Replace(texttoreplace, "=", "&")
 
Selection.Range = TexttoReplace
 
 
End Sub


Regards Mark Kofler


> On 3 Dec 2014, at 9:49 am, Geoffrey <geoffrey@xxxxxxxxxxxxxx> wrote:
> 
> Thanks Rhonda, but this just alteration also changed subsequent paragraphs 
> and then went into a loop that needed ESC to bring things back to life.
>  
> Cheers
>  
> Dr Geoffrey Marnell
> Principal Consultant
> Abelard Consulting Pty Ltd
> P: 03 9596 3456
> M: 0419 574 668
> F: 03 9596 3625
> Web: www.abelard.com.au
>  
> From: austechwriter-bounce@xxxxxxxxxxxxx 
> [mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Rhonda Bracey
> Sent: Wednesday, 3 December 2014 9:41 AM
> To: austechwriter@xxxxxxxxxxxxx
> Subject: atw: Re: Word macro help
>  
> Try getting rid of the .ExecuteReplace line and add this instead at the end, 
> AFTER ‘End With’:
> Selection.Find.Execute Replace:=wdReplaceAll
>  
> Rhonda.bracey@xxxxxxxxxxxxxxxx
> Website: http://cybertext.com.au
> Blog: http://cybertext.wordpress.com
>  
> From: austechwriter-bounce@xxxxxxxxxxxxx 
> [mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Geoffrey
> Sent: Wednesday, 3 December 2014 6:24 AM
> To: austechwriter@xxxxxxxxxxxxx
> Subject: atw: Word macro help
>  
> Hi austechies
>  
> I’m stuck with a Word macro. All I want to do is have = replaced by &amp;= in 
> a selection of text. This is the code that the record macro command generates:
>  
> Sub equals()
> '
> ' equals Macro
> '
> '
>     With Selection.Find
>         .ClearFormatting
>         .Replacement.ClearFormatting
>         .Text = "="
>         .Replacement.Text = "&amp;="
>         .Forward = True
>         .Wrap = wdFindAsk
>         .Format = False
>         .MatchCase = False
>         .MatchWholeWord = False
>         .MatchWildcards = False
>         .Execute Replace:=wdReplaceAll
> End With
> End Sub
>  
> The problem is that this macro replaces = with &amp;= throughout the entire 
> rest of the document, not just in the text selected. That’s not what I want.
>  
> Any ideas?
>  
>  
> Geoffrey Marnell
> Principal Consultant
> Abelard Consulting Pty Ltd
> P: 03 9596 3456
> M: 0419 574 668
> F: 03 9596 3625
> Web: www.abelard.com.au
>  

Other related posts: