Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
I am looking for code that will close all open workbooks except for the
active one and "Workbook 2" w/o saving changes. Any help is very much appreciated. Regards |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Ronbo,
Are you trying to write a macro virus??? That kind action from your code would be potentially harmful to people's data and make you a very unpopular bunny. NickH |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Sub KillWBs() 'I'm crazy and want to loose all my changes
Dim WB as Workbook Dim File1 as Workbook Set File1 = ActiveWorkbook For each WB in Application.Workbooks if WB.Name = "Workbook 2" or WB.Name = File1.Name then 'Don't Close Else WB.Close False End If Next Die_Another_Day |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
No virus, just a macro that will clean-up numerous open workbooks that have
been used in creating a master wb and are no longer needed and do not need to be saved. This saves the time of going into each and shutting them down. And it is only used on my computer. I saw code on "close all but active", but I need the active and "workbook 2" to remain open. "NickH" wrote: Ronbo, Are you trying to write a macro virus??? That kind action from your code would be potentially harmful to people's data and make you a very unpopular bunny. NickH |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Does my code do what you asked?
Die_Another_Day |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
If you are copying a worksheet to a new workbook, try moving it instead. I
have a macro that grabs several worksheets from various sources and moves them to a new workbook. When the worksheet is moved, it automatically closes the original workbook. (It's the only worksheet in the original) ChDir "\\ma-sql\erp7\FRx\IODATA\OPxRAW" Workbooks.Open Filename:="\\ma-sql\erp7\FRx\IODATA\OPxRAW\COO.xls" Sheets("COO").Select Sheets("COO").Move Befo=Workbooks("FormatOPx.xls").Sheets(1) ** You would replace anything in quotes with your data ** "Ronbo" wrote in message ... No virus, just a macro that will clean-up numerous open workbooks that have been used in creating a master wb and are no longer needed and do not need to be saved. This saves the time of going into each and shutting them down. And it is only used on my computer. I saw code on "close all but active", but I need the active and "workbook 2" to remain open. "NickH" wrote: Ronbo, Are you trying to write a macro virus??? That kind action from your code would be potentially harmful to people's data and make you a very unpopular bunny. NickH |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Thaniks for the help, however as I test the code it closes all but the active
wb (File 1). Any ideas why it is closing "workbook 2"? Ronbo "Ronbo" wrote: No virus, just a macro that will clean-up numerous open workbooks that have been used in creating a master wb and are no longer needed and do not need to be saved. This saves the time of going into each and shutting them down. And it is only used on my computer. I saw code on "close all but active", but I need the active and "workbook 2" to remain open. "NickH" wrote: Ronbo, Are you trying to write a macro virus??? That kind action from your code would be potentially harmful to people's data and make you a very unpopular bunny. NickH |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Oops. Add .xls on the end of Workbook 2 and make sure that it's spelled
correctly Die_Another_Day |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
It still does not work with .xls and spelled correctly. Any other ideas?
"Die_Another_Day" wrote: Oops. Add .xls on the end of Workbook 2 and make sure that it's spelled correctly Die_Another_Day |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
CLOSE WB
Never mind I got it. Its; If WB.Name = ("Workbook 2.xls") Or WB.Name =
File1.Name Then Thanks a a lot for the help. "Ronbo" wrote: It still does not work with .xls and spelled correctly. Any other ideas? "Die_Another_Day" wrote: Oops. Add .xls on the end of Workbook 2 and make sure that it's spelled correctly Die_Another_Day |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
why do all excel worksheets/workbooks close when I close one? | Excel Discussion (Misc queries) | |||
Not close thead when I close excel | Excel Programming | |||
close button does not close | Excel Discussion (Misc queries) | |||
Excel shoud not close all active books when clicking close button | Excel Discussion (Misc queries) | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel |