Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide all Sheets in Workbook then Close Workbook RyanH Excel Programming 0 January 29th 08 12:59 PM
Open New Workbook / Save and Close Current Workbook Joe K. Excel Programming 1 December 7th 07 08:04 PM
Closing a workbook from a macro doesn't close the workbook Dave P Excel Programming 2 July 10th 07 06:16 PM
Help on Workbook close and workbook save events Adam Harding Excel Programming 1 September 29th 05 04:12 PM
Close a the current workbook and load another specified workbook Adrian[_7_] Excel Programming 4 August 7th 04 05:29 PM


All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"