View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Closing a possible Workbook

Dim bk as Workbook
on error resume next
set bk = Workbooks("Mybookname.xls")
On error goto 0
if not bk is nothing then
bk.close Savechanges:=True
End if

--
Regards,
Tom Ogilvy


"kyle" wrote:

I have a program that I need to error proof and I want to close a workbook if
its open. I was wondering what my If statement would be if this certain
workbook was open so it would close, otherwise not worry about it.

if ???????????? then
workbooks(wFilename).close
else
endif

Thanks,
Kyle