View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Juan Pablo González Juan Pablo González is offline
external usenet poster
 
Posts: 226
Default Closing a workbook programmatically

Try with

currentBook.Close

instead

--
Regards

Juan Pablo González

"Raul" wrote in message
...
I am loosely using the workbooks.open method to open a
workbook and then extracting some data from it. The
routine opens the workbook and gets the desired
information. However, I'd like to close the workbook
before moving on to other steps but I can't seem do it.

Can anyone help me out with this one?

.....
Workbooks.Open "K:\AAAA\BBBB\CCCC\excelfile.xls"
Set currentBook = Application.ActiveWorkbook
'do other stuff

Workbooks(currentBook).Close
....
The routine doesn't crash, it just doesn't close the
workbook. I don't need to save any changes to the file I
want to close. I also have other workbooks open that I
don't want closed.

Thanks,
Raul