Joanne said:
Could someone clarify what the difference is between
.Execute (Replace:=wdReplaceall)
and
.Execute Replace:=wdReplaceall
with the "Find" object. I know this is a stupid question but I'm not
sure when to use the () and when not to.
Thank you very much.
It is *not* a stupid question. It's a consequence of a stupid design
decision by the programmers who created VB and VBA.
The article at
http://word.mvps.org/faqs/macrosvba/BracketsWithArgmnts.htm
explains when to use or not use parentheses for functions and subroutines in
general. In the specific case you're asking about, .Execute can be used as
*either* a function (it returns a Boolean true/false value saying whether or
not it found the search text) *or* a subroutine (you don't want the value,
you just want to search).
When you assign the result to a variable
bFound = .Execute(Replace:=wdReplaceall)
or when you use the implied result as a condition in an If statement
If .Execute(Replace:=wdReplaceall) Then
you use the parentheses. When you just fire off the search, you don't.
The stupid part is that the VBA interpreter can tell whether you're using
the result or not, because it complains when you do it wrong -- so why
should it care?? Just do it...