Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Closing workbooks

Hi



Struggling with the following problem.



Is it possible to close two workbooks working with VBA?



I have tried following codes:



Application.DisplayAlerts = False 'step 1
Windows("Book1.xls").Close 'step 2

Windows("Book2.xls").Close 'step 3
Application.DisplayAlerts = True 'step 4





Problem is, macro stops running after step 2!







Thanks,

Mischa






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Closing workbooks

If you close the workbook that contains the macro, the macro stops. Close
the other workbook first

Workbooks("Book2.xls").Close SaveChanges:=Fasle
ThisWorkbook.Close SaveChanges:=False

--
Regards,
Tom Ogilvy

"Mischa Browne" wrote in message
...
Hi



Struggling with the following problem.



Is it possible to close two workbooks working with VBA?



I have tried following codes:



Application.DisplayAlerts = False 'step 1
Windows("Book1.xls").Close 'step 2

Windows("Book2.xls").Close 'step 3
Application.DisplayAlerts = True 'step 4





Problem is, macro stops running after step 2!







Thanks,

Mischa








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Closing workbooks

Dear Tom,

I have tried you solution.
Still does not work, note that the macro is in "Book3.xls".

Running the macro from "book3.xls" to close "book2.xls" and "book1.xls"
is this possible?


Tkx,
Mischa



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Closing workbooks

Shouldn't be a problem

On Error goto 0
Application.EnableEvents = False
Workbooks("Book1.xls").Close SaveChanges:=False
Workbooks("Book2.xls").Close SaveChanges:=False
Application.EnableEvents = True

--
Regards,
Tom Ogilvy


"anonymous" wrote in message
...
Dear Tom,

I have tried you solution.
Still does not work, note that the macro is in "Book3.xls".

Running the macro from "book3.xls" to close "book2.xls" and "book1.xls"
is this possible?


Tkx,
Mischa



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default Closing workbooks

Hi Mischa,

try this:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/17/2004 by Unknown User
'

'
Windows("Book1").Activate
ActiveWindow.Close
Windows("Book2").Activate
ActiveWindow.Close
End Sub

HTH....Don

"anonymous" wrote:

Dear Tom,

I have tried you solution.
Still does not work, note that the macro is in "Book3.xls".

Running the macro from "book3.xls" to close "book2.xls" and "book1.xls"
is this possible?


Tkx,
Mischa



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

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
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
close workbooks without closing excel ? Clute Excel Discussion (Misc queries) 2 August 5th 06 09:50 PM
closing multi workbooks have_a_cup Excel Discussion (Misc queries) 2 June 28th 06 11:31 PM
Opening and Closing workbooks Jase Excel Programming 1 October 15th 03 06:28 AM
Closing workbooks through macro Shane Coughlan Excel Programming 1 October 7th 03 04:21 PM


All times are GMT +1. The time now is 05:44 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"