Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Hide the close X in excel

Hi,

I have a code, (below), to hide toolbars and to prevent users from
tampering. I have a macro which performs some operations and then saves and
closes the file. I have just realised that the X to close excel on the top
right corner is still visible meaning the file can be closed without using
the macro. Is it possible to also hide this feature so users must close
using the macro?

Thanks

Private mFormulaBar

Private Sub Workbook_BeforeClose()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Hide the close X in excel

Hi
Too much alteration of the excel interface will annoy your users more
than it is worth. If your users have more than one excel file open,
for example, any code will probably stop them closing those files as
well as yours, even if they are not saving your file.
Try putting your macro code that runs when excel closes into your
before_close macro, so that it runs automatically.
regards
Paul

On Apr 22, 3:04*pm, LiAD wrote:
Hi,

I have a code, (below), to hide toolbars and to prevent users from
tampering. *I have a macro which performs some operations and then saves and
closes the file. *I have just realised that the X to close excel on the top
right corner is still visible meaning the file can be closed without using
the macro. *Is it possible to also hide this feature so users must close
using the macro?

Thanks

Private mFormulaBar

Private Sub Workbook_BeforeClose()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Hide the close X in excel

How come your Workbook_BeforeClose event header does not have a "Cancel"
argument? Is the one you posted your own creation or was it provided by the
VB interface? If VB provided it, what version of Excel are you using? On my
XL2003 system, the BeforeClose event comes with the Cancel argument allowing
you to stop the user requested shut down of the workbook.

--
Rick (MVP - Excel)


"LiAD" wrote in message
...
Hi,

I have a code, (below), to hide toolbars and to prevent users from
tampering. I have a macro which performs some operations and then saves
and
closes the file. I have just realised that the X to close excel on the
top
right corner is still visible meaning the file can be closed without using
the macro. Is it possible to also hide this feature so users must close
using the macro?

Thanks

Private mFormulaBar

Private Sub Workbook_BeforeClose()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub


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
Before Close Event Hide all Worksheets then Close Application RyanH Excel Programming 0 January 24th 08 03:15 PM
Hide Close Button Excel 2007 [email protected] Excel Discussion (Misc queries) 0 May 31st 07 07:52 AM
how to close a form in vba (not hide) Pierre[_16_] Excel Programming 3 July 15th 05 06:01 PM
close (hide) toolbars Anthony Excel Discussion (Misc queries) 7 June 5th 05 03:19 PM
Hide all Excel tool/command bars except mine and reload on close Matt Jensen Excel Programming 2 December 20th 04 05:44 PM


All times are GMT +1. The time now is 11:09 AM.

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"