Find is not a native command. It has to be used as a member of one of the
objects that supports it. I think you want the Instr function to accomplish
your goal.
From help:
InStr Function
Returns a Variant (Long) specifying the position of the first occurrence of
one string within another.
Syntax
InStr([start, ]string1, string2[, compare])
The InStr function syntax has these arguments:
Part Description
start Optional. Numeric expression that sets the starting position for
each search. If omitted, search begins at the first character position. If
start contains Null, an error occurs. The start argument is required if
compare is specified.
string1 Required. String expression being searched.
string2 Required. String expression sought.
compare Optional. Specifies the type of string comparison. If compare
is Null, an error occurs. If compare is omitted, the Option Compare setting
determines the type of comparison. Specify a valid LCID (LocaleID) to use
locale-specific rules in the comparison.
LarryP said:
The code is nothing fancy, just testing whether a certain filename exists
within a filepathname. (What I'm actually using it for is to confirm that
a
user has saved a template file under another name; if not, it throws him
out.) Like this:
If Find("OriginalFile.xls", "c:\Documents And
Settings\Stuff\SavedAsFile.xls", 1) Then
MsgBox ("Naughty, naughty, same filename -- you'e outa here!")
End If
Compiling or running this, though, gives a Compile error: Sub or Function
not defined. Exact same if I use Search instead of Find.