Option Compare Text

G

Graham

Hi,

I am trying to perform a certain operation via AutoOpen
that will only run if the workbook name is "template" for
example. If the workbook name is anything else I would
like AutoOpen to ignore the procedure. I have been advised
to use Option Compare Text, but I don't know how! Help
please!

Thanks
Graham
 
F

Frank Kabel

Hi
maybe something like
If LCase(activeworkbook.name) = "template" then
'do something
end if
 
C

Chip Pearson

Graham,

If you put 'Option Compare Text' at the very top of the code
module (not the procedure), all text comparisons in that module
will be case-insensitive. Short of that, you can use StrComp to
compare two strings and see if they are equal. E.g.,

If StrComp(ActiveWorkbook.Name, "template", vbTextCompare) = 0
Then
' strings are equal
Else
' strings are not equal
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top