Replace Dialog

J

JBNewsGroup

Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced with
the degree symbol followed by an F or C. Since the word "degree" may have
any combination of upper and lower case letters I have search strings
defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not have to
be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
J

JBNewsGroup

Hi Greg,

Thanks for your response.

Yes I tried "degree" and "degrees" but because of the "-" it seems that I
could not use MatchAllWordForms and had to use MatchWildCards and
PatternMatch. If I did not have the "-" then it works with "degree" and
"degrees".

Jerry Bodoff

Greg Maxey said:
Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
T

Tony Jollans

Can you give a bit more detail of what you're doing. Looking for all word
forms of "degree" returns degree DeGreeS, etc whether preceded by "-" or "+"
or all manner of other symbols - much the same way as your posted find text
will. How are you controlling which instances get replaced?

--
Enjoy,
Tony


JBNewsGroup said:
Hi Greg,

Thanks for your response.

Yes I tried "degree" and "degrees" but because of the "-" it seems that I
could not use MatchAllWordForms and had to use MatchWildCards and
PatternMatch. If I did not have the "-" then it works with "degree" and
"degrees".

Jerry Bodoff

Greg Maxey said:
Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
G

Graham Mayor

Search for
<[degrsDEGRS]{6,7}>
or if you want to tie it down even tighter
<[dD]{1}[egrEGR]{4}[eEsS]{1,2}>

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Hi Greg,

Thanks for your response.

Yes I tried "degree" and "degrees" but because of the "-" it seems
that I could not use MatchAllWordForms and had to use MatchWildCards
and PatternMatch. If I did not have the "-" then it works with
"degree" and "degrees".

Jerry Bodoff

Greg Maxey said:
Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
J

JBNewsGroup

Hi Tony,

Here is the original code that I am trying to improve:
----------------------------------------------------------------------------
--------------------
Private Sub ConvertDegrees (FCDegree as string) ' degree symbol and F or
C
Dim J As Integer
Dim DegreeText As String
Dim FindText As String

DegreeText = "[Dd][Ee][Gg][Rr][Ee][Ee]"

For J = 1 To 4
Select Case J ' Define
Search Text
Case 1
FindText = "-" & DegreeText & ">"
Case 2
FindText = " " & DegreeText & ">"
Case 3
FindText = "-" & DegreeText & "[Ss]>"
Case 4
FindText = " " & DegreeText & "[Ss]>"
End Select

Selection.HomeKey Unit:= wdStory ' Start Search at start
of Document
With Selection.Find ' Check if
any FindText string
.ClearFormatting
.Text = FindText
.MatchWildCards = True

If .Execute Then ' If True
then FindString in Document
With Dialogs(wdDialogEditReplace) ' Use Dialogs for
interaction to determine
'
replace or no replace
.Find = FindText
.Replace = FCDegree
.PatternMatch = True
SendKeys "%F", True ' Initialize
Dialog to first FindString
On Error Resume Next ' Probably do not
need, leave for now
If (.Show = 0) Then Exit For ' Search & Replace
cancelled
End With
End If
End With
Next J
Selection.HomeKey Unit:=wdStory ' Set to start of
document for next conversion step
End Sub
----------------------------------------------------------------------------
--------------------
What I have now seems to work but there has to be a better way, especially
when I have "tons" of documents to convert.

Thanks for your help.

Jerry Bodoff

Tony Jollans said:
Can you give a bit more detail of what you're doing. Looking for all word
forms of "degree" returns degree DeGreeS, etc whether preceded by "-" or "+"
or all manner of other symbols - much the same way as your posted find text
will. How are you controlling which instances get replaced?

--
Enjoy,
Tony


JBNewsGroup said:
Hi Greg,

Thanks for your response.

Yes I tried "degree" and "degrees" but because of the "-" it seems that I
could not use MatchAllWordForms and had to use MatchWildCards and
PatternMatch. If I did not have the "-" then it works with "degree" and
"degrees".

Jerry Bodoff

Greg Maxey said:
Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

JBNewsGroup wrote:
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
T

Tony Jollans

Well, you are probably doing about as well as you can with a straightforward
Find and Replace although some crafted code could be a bit more precise.
Whether it's worth it probably depends on how often degree is prefixed with
anything other than a hyphen.

As you seem to require a manual confirmation of every replacement I'm not
sure you are gaining much over just looking for all word forms of "degree"
but, again, that would depend on the rest of the content of your documents.

--
Enjoy,
Tony


JBNewsGroup said:
Hi Tony,

Here is the original code that I am trying to improve:
-------------------------------------------------------------------------- --
--------------------
Private Sub ConvertDegrees (FCDegree as string) ' degree symbol and F or
C
Dim J As Integer
Dim DegreeText As String
Dim FindText As String

DegreeText = "[Dd][Ee][Gg][Rr][Ee][Ee]"

For J = 1 To 4
Select Case J ' Define
Search Text
Case 1
FindText = "-" & DegreeText & ">"
Case 2
FindText = " " & DegreeText & ">"
Case 3
FindText = "-" & DegreeText & "[Ss]>"
Case 4
FindText = " " & DegreeText & "[Ss]>"
End Select

Selection.HomeKey Unit:= wdStory ' Start Search at start
of Document
With Selection.Find ' Check if
any FindText string
.ClearFormatting
.Text = FindText
.MatchWildCards = True

If .Execute Then ' If True
then FindString in Document
With Dialogs(wdDialogEditReplace) ' Use Dialogs for
interaction to determine
'
replace or no replace
.Find = FindText
.Replace = FCDegree
.PatternMatch = True
SendKeys "%F", True ' Initialize
Dialog to first FindString
On Error Resume Next ' Probably do not
need, leave for now
If (.Show = 0) Then Exit For ' Search & Replace
cancelled
End With
End If
End With
Next J
Selection.HomeKey Unit:=wdStory ' Set to start of
document for next conversion step
End Sub
-------------------------------------------------------------------------- --
--------------------
What I have now seems to work but there has to be a better way, especially
when I have "tons" of documents to convert.

Thanks for your help.

Jerry Bodoff

Tony Jollans said:
Can you give a bit more detail of what you're doing. Looking for all word
forms of "degree" returns degree DeGreeS, etc whether preceded by "-" or "+"
or all manner of other symbols - much the same way as your posted find text
will. How are you controlling which instances get replaced?
that
I
could not use MatchAllWordForms and had to use MatchWildCards and
PatternMatch. If I did not have the "-" then it works with "degree" and
"degrees".

Jerry Bodoff

Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

JBNewsGroup wrote:
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
J

JBNewsGroup

Hi,

Thanks for all the suggestions and comments Greg, Tony and Graham.
I really appreciate the help.

Jerry Bodoff
 
J

JBNewsGroup

Hi Graham,

Thanks a lot. After analyzing the documents I realized that the only
conversions are when the "degree" string is preceded by any digit followed
by 1 or more "-" or blank. Therefore, I was able to completely eliminate
the Dialogs interaction by using the following:

Search ([0123456789])[- ]{1,}<[dD]{1}[egrEGR]{4}[eEsS]{1,2}>
Replace \1°F or \1°C (F or C passed as an argument)

I assume that the {4} after [egrEGR] also encompasses the [dD]{1}
expression.

Really appreciate your help.

Jerry Bodoff

Graham Mayor said:
Search for
<[degrsDEGRS]{6,7}>
or if you want to tie it down even tighter
<[dD]{1}[egrEGR]{4}[eEsS]{1,2}>

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Hi Greg,

Thanks for your response.

Yes I tried "degree" and "degrees" but because of the "-" it seems
that I could not use MatchAllWordForms and had to use MatchWildCards
and PatternMatch. If I did not have the "-" then it works with
"degree" and "degrees".

Jerry Bodoff

Greg Maxey said:
Have you tried simply using degree and degrees?

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

JBNewsGroup wrote:
Hi,

General question with WORD2000.

I have a search string for the word "degree" which is to be replaced
with the degree symbol followed by an F or C. Since the word
"degree" may have any combination of upper and lower case letters I
have search strings defined as:

-[Dd][Ee][Gg][Rr][Ee][Ee]>
-[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>
[Dd][Ee][Gg][Rr][Ee][Ee]>
[Dd][Ee][Gg][Rr][Ee][Ee][Ss]>

Is there a better way to define the search strings?

I am using the EditReplace dialog since some "degree" words may not
have to be replaced.

Thanks in advance for any hints.

Jerry Bodoff
 
G

Graham Mayor

JBNewsGroup said:
I assume that the {4} after [egrEGR] also encompasses the [dD]{1}
expression.

No - they are separate strings D or d followed by any four of the next
batch. for them to be part ofnthe same expression you would need
[degrDEGR]{5}

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

JBNewsGroup

Hi Graham,

Thanks.

Jerry Bodoff
Graham Mayor said:
JBNewsGroup said:
I assume that the {4} after [egrEGR] also encompasses the [dD]{1}
expression.

No - they are separate strings D or d followed by any four of the next
batch. for them to be part ofnthe same expression you would need
[degrDEGR]{5}

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top