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
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
> 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 "+"
[quoted text clipped - 46 lines]
> > > >
> > > > Jerry Bodoff
Tony Jollans - 14 Nov 2005 17:25 GMT
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
> Hi Tony,
>
[quoted text clipped - 34 lines]
> With Dialogs(wdDialogEditReplace) ' Use Dialogs for
> interaction to determine
'
> replace or no replace
> .Find = FindText
[quoted text clipped - 75 lines]
> > > > >
> > > > > Jerry Bodoff