Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide all Sheets in Workbook then Close Workbook | Excel Programming | |||
Open New Workbook / Save and Close Current Workbook | Excel Programming | |||
Closing a workbook from a macro doesn't close the workbook | Excel Programming | |||
Help on Workbook close and workbook save events | Excel Programming | |||
Close a the current workbook and load another specified workbook | Excel Programming |