View Single Post
  #3   Report Post  
JulieD
 
Posts: n/a
Default

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