Number of Replacements?

G

George Lee

How can you get the total number of replacements after using Find/Replace
with wdReplaceAll?
 
H

Helmut Weber

Hi everybody,

I wonder...:

Sub test45620()
Dim strResult As String
Dim lngResult As String
Dim l As Long
Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogEditReplace)
On Error Resume Next
oDlg.Display
strResult = Err.Description
For l = 1 To Len(strResult)
If IsNumeric(Mid(strResult, l, 1)) Then
lngResult = lngResult & Mid(strResult, l, 1)
End If
Next
MsgBox "number of replacements = " & lngResult
End Sub


Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
G

George Lee

Thanks for the idea. I also saw Helmut's suggestion and although they are
both useful, they're not very elegant solutions. That's no one's fault but it
is curious what Microsoft decides to exposure and what they hide.
 
G

George Lee

Funny, that message with the number of replacements is really an error.
However, the dialog only appears if the dialog is actually displayed? If you
access it programmatically (through VBA code), you can't get it?
 

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