Home |
Search |
Today's Posts |
#1
|
|||
|
|||
prohibit closing a workbook
Hi,
I have a program that uses 2 workbooks. Both must be visible. But the code workbook with the graphics cannot be closed by the right corner cross clicking. How can i prevent this from happening. The code workbook closes automaticcly by closing the other data workbook Thenks for helping me out |
#2
|
|||
|
|||
Place this in the ThisWorkbook module of the target
workbook: Private Sub Workbook_BeforeClose(Cancel As Boolean) Cancel = True End Sub --- HTH Jason Atlanta, GA -----Original Message----- Hi, I have a program that uses 2 workbooks. Both must be visible. But the code workbook with the graphics cannot be closed by the right corner cross clicking. How can i prevent this from happening. The code workbook closes automaticcly by closing the other data workbook Thenks for helping me out . |
#3
|
|||
|
|||
Hi Christophero
this code will stop the workbook closing if "book3" is open (change the name as required) --- Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error GoTo err_handler If Len(Application.Workbooks("Book3.xls").Name) 0 Then Cancel = True End If err_handler: End Sub --- to use the code, right mouse click on a sheet tab of the book you do not want to be able to close directly, choose view code to display the vbe window, on the left you should see your workbook's name in bold and under that sheet1, sheet2 etc (if you can't see this choose view / project explorer from the menu) under the workbook's name you should see ThisWorkbook - double click on ThisWorkbook and copy & paste the code into the right hand side of the screen. now use alt & F11 to switch back to your workbook and attempt to close the book. it should not be possible while the other book is open. i hope this will work in with your current code. -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "Christophero" wrote in message ... Hi, I have a program that uses 2 workbooks. Both must be visible. But the code workbook with the graphics cannot be closed by the right corner cross clicking. How can i prevent this from happening. The code workbook closes automaticcly by closing the other data workbook Thenks for helping me out |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? | Excel Worksheet Functions | |||
How to hyperlink from a workbook to sheets in another workbook? | Excel Worksheet Functions | |||
Unprotect Workbook | Excel Discussion (Misc queries) | |||
make hidden window or workbook visible without specify the name | Excel Worksheet Functions | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) |