DECLARATION ERROR.Compile Error: Invalid Procedure

D

Designingsally

Hi I have been getting this error messaget when i m executing the macro given
below. I know the macro is perfect. I think the problem lies with the
declaration. When i m trying to use -/ or some other special characters this
problem is ocuring.

post me ur thoughts into this thanks in advance
Dim orng As Range
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "Re-enter" 'the word to find
sRepText = "reenter" 'the word to replace
With Selection
..HomeKey wdStory
With .FInd
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = True
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("The Recommended Word is and so on. Replace?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
End With
End With
End Sub
 
D

Doug Robbins - Word MVP

Do you have

Sub something()

before the

Dim orng As Range?

The code works fine here.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Pesach Shelnitz

Hi Sally,

The constant returned by a Msgbox is not a String. Change

Dim sRep As String

to

Dim sRep As VbMsgBoxResult
 

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