Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Enabling / Disabling Menu Items..!


I have created a menu bar using the following VBA (relevant portion
anyway):

' Add a new menu EMPLOYEES
Set NewMenu = NewMenuBar.Controls.Add _
(Type:=msoControlPopup)
NewMenu.Caption = "&Employees"

' Add a new menu item SHOW INFO
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
..Caption = "&Show Info"
..OnAction = "OpenStaffInfo"
End With

' Add a new menu item HIDE INFO
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
..Caption = "&Hide Info"
..OnAction = "HideStaffinfo"
End With

---I have tried everything syntax-wise to disable each menu item if the
other one is selected, putting the code in each sub:

Sub OpenStaffInfo()
Columns("A:C").Select
Selection.EntireColumn.Hidden = False
‘ Disable this menu option code here (nothing seems to work!)
‘ Enable Hide Staff Info menu option here (nothing seems to work!)
End Sub

Sub HideStaffInfo()
Columns("A:C").Select
Selection.EntireColumn.Hidden = True
‘ Disable this menu option code here (nothing seems to work!)
‘ Enable Open Staff Info menu option here (nothing seems to
work!)
End Sub

VBA help and all my books still lead me to syntax errors...I am still a
bit of a novice no formal training

Help would be very appreciated...I am so close this drives me crazy!

-Dave


--
Applewine
------------------------------------------------------------------------
Applewine's Profile: http://www.excelforum.com/member.php...fo&userid=5512
View this thread: http://www.excelforum.com/showthread...hreadid=378671

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Help with Enabling / Disabling Menu Items..!

One way:

With .Controls.Add(Type:=msoControlPopup)
.Caption = "&Employees"

' Add a new menu item SHOW INFO
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Show Info"
.OnAction = "OpenStaffInfo"
.Tag = "abcShow"
.Enabled = Range("A:C").EntireColumn.Hidden
End With

' Add a new menu item HIDE INFO
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Hide Info"
.OnAction = "HideStaffinfo"
.Tag = "abcHide"
.Enabled = Not Range("A:C").EntireColumn.Hidden
End With
End With


Public Sub OpenStaffInfo()
Columns("A:C").EntireColumn.Hidden = False
CommandBars.FindControl(Tag:="abcShow").Enabled = False
CommandBars.FindControl(Tag:="abcHide").Enabled = True
End Sub

Public Sub HideStaffInfo()
Columns("A:C").EntireColumn.Hidden = True
CommandBars.FindControl(Tag:="abcShow").Enabled = True
CommandBars.FindControl(Tag:="abcHide").Enabled = False
End Sub


In article ,
Applewine
wrote:

I have created a menu bar using the following VBA (relevant portion
anyway):

' Add a new menu EMPLOYEES
Set NewMenu = NewMenuBar.Controls.Add _
(Type:=msoControlPopup)
NewMenu.Caption = "&Employees"

' Add a new menu item SHOW INFO
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
.Caption = "&Show Info"
.OnAction = "OpenStaffInfo"
End With

' Add a new menu item HIDE INFO
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
.Caption = "&Hide Info"
.OnAction = "HideStaffinfo"
End With

---I have tried everything syntax-wise to disable each menu item if the
other one is selected, putting the code in each sub:

Sub OpenStaffInfo()
Columns("A:C").Select
Selection.EntireColumn.Hidden = False
‘ Disable this menu option code here (nothing seems to work!)
‘ Enable Hide Staff Info menu option here (nothing seems to work!)
End Sub

Sub HideStaffInfo()
Columns("A:C").Select
Selection.EntireColumn.Hidden = True
‘ Disable this menu option code here (nothing seems to work!)
‘ Enable Open Staff Info menu option here (nothing seems to
work!)
End Sub

VBA help and all my books still lead me to syntax errors...I am still a
bit of a novice no formal training

Help would be very appreciated...I am so close this drives me crazy!

-Dave

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
enabling/disabling a set of code from within a spreadsheet sheet Roger on Excel Excel Discussion (Misc queries) 2 November 17th 07 05:04 PM
Enabling sub menu items via vba Dan Neely Excel Worksheet Functions 0 July 11th 05 04:48 PM
Disabling/Enabling Macros HRobertson Excel Programming 2 October 24th 03 04:07 PM
Disabling menu items in VBE Michael Singmin Excel Programming 1 October 10th 03 01:39 PM
Enabling/Disabling Macros David Excel Programming 6 August 12th 03 06:21 PM


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