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