Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Christophero
 
Posts: n/a
Default 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   Report Post  
Jason Morin
 
Posts: n/a
Default

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   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



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
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
How to hyperlink from a workbook to sheets in another workbook? MJOHNSON Excel Worksheet Functions 0 February 17th 05 08:31 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
make hidden window or workbook visible without specify the name mango Excel Worksheet Functions 1 December 30th 04 03:05 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


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