Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default How to Disable/Enable hide entire row ability

On 06/30/2014 5:02 PM, symbiosis001 wrote:
incidentally... if the code is also placed in the following

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
gbShuttingDown = True: ShutdownApp
End Sub

Then the menus will unlock when the user swaps to a different workbook and using the code below will lock again when the user swaps back to this workbook.

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
gbShuttingDown = False: ShutdownApp
End Sub

Sym

This changes the structure of your project such that
EnableDisable_BuiltinCtrls is no longer used exclusively at
startup/shutdown. In this case you need to make it generic so it can be
called from anywhere in your project. This means changing your project
as follows...

In a standard module named "m_OpenClose":

Option Explicit

Public Const gsMenusToDisable$ _
= "Worksheet Menu Bar:F&ormat:&Row:&Unhide" _
& ",Worksheet Menu Bar:F&ormat:$Row:&Hide" _
& ",Worksheet Menu Bar:F&ormat:&Column:&Unhide" _
& ",Worksheet Menu Bar:F&ormat:&Column:&Hide" _
& ",Row:&Hide,Row:&Unhide" _
& ",Column:&Hide,Column:&Unhide"
Public gbShuttingDown As Boolean
'...any other global scope variables/constants use by this project


Sub Auto_Open()
'...
'Disable builtin menus/controls not to be used
EnableDisable_BuiltinCtrls gbShuttingDown
'...
End Sub

Sub Auto_Close()
gbShuttingDown = True: ShutdownApp
End Sub

Sub ShutdownApp()
'Restore disabled builtin menus/controls
EnableDisable_BuiltinCtrls gbShuttingDown
'...other shutdown code
End Sub

Sub InitGlobals()
' Used to initialize global variables with runtime values
'...
End Sub

...where this should (IMO) be the default standard module for all
projects. I don't use the 'Microsoft Excel Objects' for any purpose and
so Excel events are handled by a Class Module. I can provide code for
this if you wish, but for now I'll just example how to code your Window
Activate/Deactivate events in the 'ThisWorkbook' component of your
project...

Option Explicit

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
EnableDisable_BuiltinCtrls False
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
EnableDisable_BuiltinCtrls True
End Sub


Finally, change EnableDisable_BuiltinCtrls as follows.

Sub EnableDisable_BuiltinCtrls(bEnabled As Boolean)
Dim vSz, vCtls, ctl As Object
On Error Resume Next '//can't toggle disabled context menus
For Each vSz In Split(gsMenusToDisable, ",")
vCtls = Split(vSz, ":")
Select Case UBound(vCtls)
Case Is = 1
CommandBars(vCtls(0)).Controls(vCtls(1)).Enabled = bEnabled
Case Is = 2

CommandBars(vCtls(0)).Controls(vCtls(1)).Controls( vCtls(2)).Enabled =
bEnabled
Case Is = 3

CommandBars(vCtls(0)).Controls(vCtls(1)).Controls( vCtls(2)).Controls(vCtls(3)).Enabled
= bEnabled
Case Is = 4

CommandBars(vCtls(0)).Controls(vCtls(1)).Controls( vCtls(2)).Controls(vCtls(3)).Controls(vCtls(4)).En abled
= bEnabled
Case Is = 5

CommandBars(vCtls(0)).Controls(vCtls(1)).Controls( vCtls(2)).Controls(vCtls(3)).Controls(vCtls(4)).Co ntrols(vCtls(5)).Enabled
= bEnabled
End Select
Next 'vSz
End Sub

--
Regards,
Garry

Free Usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
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
is it possible to disable the ability to save a file unless the u. AucklandAssault Excel Discussion (Misc queries) 2 November 8th 06 08:52 PM
Disable ability to Protect CLR Excel Programming 2 April 12th 06 05:14 PM
Hide Enable/Disable Startup Zurn[_29_] Excel Programming 4 February 21st 06 04:44 PM
Hide Enable/Disable Macro pop-up when file opens steve Excel Worksheet Functions 3 April 12th 05 04:50 PM
enable / disable macros Tiffany[_3_] Excel Programming 1 December 22nd 03 11:48 PM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"