IF file name

F

flow23

This is easy but somehow I cant get it

I have a macro that I want to execute only if the workbook has a particualr
file name

so something like
If workbooks.name = " sample.xls" then
' do something
else
' do nothing
end if
end sub

however, what I found was that no matter what the file name, the macro still
goes ahead and get executed
 
D

Dave Peterson

dim wkbk as workbook
set wkbk = activeworkbook

if trim(lcase(wkbk.name)) = trim(lcase("sample.xls")) then
'do something
else
'do something else
end if
 
F

flow23

many thanks


Dave Peterson said:
dim wkbk as workbook
set wkbk = activeworkbook

if trim(lcase(wkbk.name)) = trim(lcase("sample.xls")) then
'do something
else
'do something else
end if
 
Top