Thread: IF file name
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default IF file name

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



flow23 wrote:

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


--

Dave Peterson