atw: Re: Word macro help

  • From: jjw@xxxxxxxxx
  • To: austechwriter@xxxxxxxxxxxxx
  • Date: Wed, 03 Dec 2014 11:32:31 +1300

This discussion on Stackoverflow might help:

http://stackoverflow.com/questions/14515433/word-2010-vba-replace-within-a-highlighted-range

J

Quoting Geoffrey <geoffrey@xxxxxxxxxxxxxx>:

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:  <http://www.abelard.com.au/> www.abelard.com.au






**************************************************
To view the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field (without quotes).

To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go 
to www.freelists.org/list/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts: