Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing a possible Workbook
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing a possible Workbook
didn't see your code, so modify mine to
Dim bk as Workbook on error resume next set bk = Workbooks(wFilename) On error goto 0 if not bk is nothing then bk.close Savechanges:=True End if where wFilename should be myworkbook.xls, not something like C:\Myfolder\myworkbook.xls -- Regards, Tom Ogilvy "Tom Ogilvy" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Closing Hidden Workbook when Active Workbook is Closed | Excel Programming | |||
Help with closing down a workbook?? | Excel Worksheet Functions | |||
Closing a workbook... | Excel Programming | |||
closing excel after closing a workbook | Excel Programming | |||
Closing a workbook | Excel Programming |