Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Dull addin menu item

Hello,

Is it possible to dull the menu item of an addin that I've created when a
workbook isn't open, if so, advise much appreciated. Rob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dull addin menu item

set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created when a
workbook isn't open, if so, advise much appreciated. Rob




  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Dull addin menu item

Bob,

Can you please point me in the right direction as to where in the code below
I would enter False to disable and how to switch to active (True) once a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created when a
workbook isn't open, if so, advise much appreciated. Rob






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dull addin menu item

Rob,

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
.Enabled = False
.Tag = "ResetCell"
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub

I added a tag to make it easy to find again, so you can enable with

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Can you please point me in the right direction as to where in the code

below
I would enter False to disable and how to switch to active (True) once a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created when

a
workbook isn't open, if so, advise much appreciated. Rob








  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Dull addin menu item

Bob,

Setting Enabled = False makes the menu item inactive as required but what
would cause the following code to run when any workbook is open. I can add
this code to Auto Open in a known file and the menu item becomes active but
I need to activate the menu when any workbook is opened.

Your help is much appreciated. Rob

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With


"Bob Phillips" wrote in message
...
Rob,

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
.Enabled = False
.Tag = "ResetCell"
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub

I added a tag to make it easy to find again, so you can enable with

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Can you please point me in the right direction as to where in the code

below
I would enter False to disable and how to switch to active (True) once a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created
when

a
workbook isn't open, if so, advise much appreciated. Rob












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dull addin menu item

Rob,

You need to enable application events. This a multi-step process, which I
would add to the same workbook as that menu code

This is what you should so


Firstly, all of this code goes in the designated workbook.



'========================================Insert a class module, rename it to
'clsAppEvents', with this code

Option Explicit


Public WithEvents App As Application


Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim NewMenuItem As CommandBarButton

With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With
End Sub


'========================================In ThisWorkbook code module, add
this event code

Dim AppClass As New clsAppEvents


Private Sub Workbook_Open()


Set AppClass.App = Application


End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Setting Enabled = False makes the menu item inactive as required but what
would cause the following code to run when any workbook is open. I can

add
this code to Auto Open in a known file and the menu item becomes active

but
I need to activate the menu when any workbook is opened.

Your help is much appreciated. Rob

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With


"Bob Phillips" wrote in message
...
Rob,

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
.Enabled = False
.Tag = "ResetCell"
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub

I added a tag to make it easy to find again, so you can enable with

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Can you please point me in the right direction as to where in the code

below
I would enter False to disable and how to switch to active (True) once

a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created
when

a
workbook isn't open, if so, advise much appreciated. Rob












  #7   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Dull addin menu item

Bob,
This isn't working for me, is it because its an Addin and this can't sense
whether or not a workbook is open or not? I already had Call AddMenuItem in
the Workbook_Open() but this doesn't appear to be required with your
suggested text, however, the menu item is still active when there's no
workbook open.

I've had a look at some other Addins and these also show active menu items
even though they do nothing until a workbook is open. Maybe I'm too fussy!

Regards, Rob

"Bob Phillips" wrote in message
...
Rob,

You need to enable application events. This a multi-step process, which I
would add to the same workbook as that menu code

This is what you should so


Firstly, all of this code goes in the designated workbook.



'========================================Insert a class module, rename it
to
'clsAppEvents', with this code

Option Explicit


Public WithEvents App As Application


Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim NewMenuItem As CommandBarButton

With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With
End Sub


'========================================In ThisWorkbook code module, add
this event code

Dim AppClass As New clsAppEvents


Private Sub Workbook_Open()


Set AppClass.App = Application


End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Setting Enabled = False makes the menu item inactive as required but what
would cause the following code to run when any workbook is open. I can

add
this code to Auto Open in a known file and the menu item becomes active

but
I need to activate the menu when any workbook is opened.

Your help is much appreciated. Rob

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With


"Bob Phillips" wrote in message
...
Rob,

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
.Enabled = False
.Tag = "ResetCell"
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub

I added a tag to make it easy to find again, so you can enable with

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Can you please point me in the right direction as to where in the code
below
I would enter False to disable and how to switch to active (True) once

a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've created
when
a
workbook isn't open, if so, advise much appreciated. Rob














  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dull addin menu item

Rob,

It should all be fine. You do need the have the menu code in Workbook_Open
as well.

Send me the workbook, I will sort it for you (be quick, the festivities
start soon :-)).

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,
This isn't working for me, is it because its an Addin and this can't sense
whether or not a workbook is open or not? I already had Call AddMenuItem

in
the Workbook_Open() but this doesn't appear to be required with your
suggested text, however, the menu item is still active when there's no
workbook open.

I've had a look at some other Addins and these also show active menu items
even though they do nothing until a workbook is open. Maybe I'm too

fussy!

Regards, Rob

"Bob Phillips" wrote in message
...
Rob,

You need to enable application events. This a multi-step process, which

I
would add to the same workbook as that menu code

This is what you should so


Firstly, all of this code goes in the designated workbook.



'========================================Insert a class module, rename

it
to
'clsAppEvents', with this code

Option Explicit


Public WithEvents App As Application


Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim NewMenuItem As CommandBarButton

With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With
End Sub


'========================================In ThisWorkbook code module,

add
this event code

Dim AppClass As New clsAppEvents


Private Sub Workbook_Open()


Set AppClass.App = Application


End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Setting Enabled = False makes the menu item inactive as required but

what
would cause the following code to run when any workbook is open. I can

add
this code to Auto Open in a known file and the menu item becomes active

but
I need to activate the menu when any workbook is opened.

Your help is much appreciated. Rob

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With

"Bob Phillips" wrote in message
...
Rob,

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
.Enabled = False
.Tag = "ResetCell"
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub

I added a tag to make it easy to find again, so you can enable with

Dim NewMenuItem As CommandBarButton
With Application.CommandBars
Set NewMenuItem = .FindControl(Tag:="ResetCell")
NewMenuItem.Enabled = True
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Bob,

Can you please point me in the right direction as to where in the

code
below
I would enter False to disable and how to switch to active (True)

once
a
workbook is open.

Thanks, Rob

Sub AddMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

' Delete the menu if it already exists
Call DeleteMenuItem

' Find the Tools Menu
Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add a menu item."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&Reset last cell on each worksheet"
.FaceId = 10
' .ShortcutText = "Ctrl+Shift+C"
.OnAction = "DeleteUnused"
.BeginGroup = True
End With
End If

' Create the shortcut key
' Application.MacroOptions _
' Macro:="DeleteUnused", _
' HasShortcutKey:=True, _
' ShortcutKey:=""
End Sub
"Bob Phillips" wrote in message
...
set the enabled property to false.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
Hello,

Is it possible to dull the menu item of an addin that I've

created
when
a
workbook isn't open, if so, advise much appreciated. Rob
















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
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 PM
New menu bar item Juan[_3_] Excel Programming 3 May 15th 04 10:43 AM
unknown menu appear when installing an AddIn Carl Excel Programming 0 December 23rd 03 09:19 AM
Excel Addin with drop-down menu Aparna Rege Excel Programming 1 July 14th 03 11:00 PM


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