![]() |
Close a workbook
Hi
When closing one workbook I want it to close another. I have tried Workbooks("C:XXX\BOOK1.XLS").Close SaveChanges:=False Which doesnt seem to work. Without making the other workbook active is there any other way to close it? Many thanks Simon |
Close a workbook
Hi Simon
"C:XXX\BOOK1.XLS" is probably not a valid path. Maybe you do not need a path. HTH. Best wishes Harald "Simon" wrote in message ... Hi When closing one workbook I want it to close another. I have tried Workbooks("C:XXX\BOOK1.XLS").Close SaveChanges:=False Which doesnt seem to work. Without making the other workbook active is there any other way to close it? Many thanks Simon |
Close a workbook
Sorry,
Forgot to mention that I also need code to check whether the workbook is actually open. I am using v2007 "Simon" wrote: Hi When closing one workbook I want it to close another. I have tried Workbooks("C:XXX\BOOK1.XLS").Close SaveChanges:=False Which doesnt seem to work. Without making the other workbook active is there any other way to close it? Many thanks Simon |
Close a workbook
Once the workbook is open, excel doesn't need or want that drive and path.
Try: Workbooks("BOOK1.XLS").Close SaveChanges:=False In fact, you may want to open it nicely, too: Dim wkbk as workbook set wkbk = workbooks(filename:="c:\xxx\book1.xls") 'do lots of stuff wkbk.close savechanges:=false When you're opening the file, you'll want to tell excel where to look -- not just rely on the current directory. Simon wrote: Hi When closing one workbook I want it to close another. I have tried Workbooks("C:XXX\BOOK1.XLS").Close SaveChanges:=False Which doesnt seem to work. Without making the other workbook active is there any other way to close it? Many thanks Simon -- Dave Peterson |
Close a workbook
I'd just ignore any error:
on error resume next workbooks("book1.xls").close savechanges:=false on error goto 0 Simon wrote: Sorry, Forgot to mention that I also need code to check whether the workbook is actually open. I am using v2007 "Simon" wrote: Hi When closing one workbook I want it to close another. I have tried Workbooks("C:XXX\BOOK1.XLS").Close SaveChanges:=False Which doesnt seem to work. Without making the other workbook active is there any other way to close it? Many thanks Simon -- Dave Peterson |
All times are GMT +1. The time now is 02:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com