PC Review


Reply
Thread Tools Rate Thread

Disable "Hyperlink" menu item

 
 
Murray
Guest
Posts: n/a
 
      28th Feb 2007
Greetings

The following piece of code works fine:

CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save
&As...").Enabled = False

However, if I change it to try and disable the Hyperlink menu item, it
will not work:

CommandBars("Worksheet Menu
Bar").Controls("Insert").Controls("Hyperl&ink...).Enabled = False

I then attempted to do it by brute force with equal lack of success:

For Each m1 In Application.CommandBars(1).Controls
For Each m2 In m1.Controls
If m2.Caption = "Hyperl&ink..." Then
m2.Enabled = False
End If
Next m2
Next m1

Can anyone please explain to me why these methods fail to disable the
Hyperlink menu item, and if there is a way to do it?

Thanks and regards

Murray

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      28th Feb 2007
Murray,
With the addition of the missing " at the end of "Hyperl&ink...", it worked
from the Immediate window:

CommandBars("Worksheet Menu
Bar").Controls("Insert").Controls("Hyperl&ink...").Enabled = False
There is also:
CommandBars("Cell").Controls("Hyperl&ink...").Enabled = False
which appears on the right-click menu of a cell.

NickHK

"Murray" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greetings
>
> The following piece of code works fine:
>
> CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save
> &As...").Enabled = False
>
> However, if I change it to try and disable the Hyperlink menu item, it
> will not work:
>
> CommandBars("Worksheet Menu
> Bar").Controls("Insert").Controls("Hyperl&ink...).Enabled = False
>
> I then attempted to do it by brute force with equal lack of success:
>
> For Each m1 In Application.CommandBars(1).Controls
> For Each m2 In m1.Controls
> If m2.Caption = "Hyperl&ink..." Then
> m2.Enabled = False
> End If
> Next m2
> Next m1
>
> Can anyone please explain to me why these methods fail to disable the
> Hyperlink menu item, and if there is a way to do it?
>
> Thanks and regards
>
> Murray
>



 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      28th Feb 2007
Hi

Or use the ID, also working in non English Excel versions then

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=1567)
Ctrl.Enabled = False
Next Ctrl
End Sub

Sub MenuControl_True()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=1576)
Ctrl.Enabled = True
Next Ctrl
End Sub


See also
http://www.rondebruin.nl/menuid.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"NickHK" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Murray,
> With the addition of the missing " at the end of "Hyperl&ink...", it worked
> from the Immediate window:
>
> CommandBars("Worksheet Menu
> Bar").Controls("Insert").Controls("Hyperl&ink...").Enabled = False
> There is also:
> CommandBars("Cell").Controls("Hyperl&ink...").Enabled = False
> which appears on the right-click menu of a cell.
>
> NickHK
>
> "Murray" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Greetings
>>
>> The following piece of code works fine:
>>
>> CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save
>> &As...").Enabled = False
>>
>> However, if I change it to try and disable the Hyperlink menu item, it
>> will not work:
>>
>> CommandBars("Worksheet Menu
>> Bar").Controls("Insert").Controls("Hyperl&ink...).Enabled = False
>>
>> I then attempted to do it by brute force with equal lack of success:
>>
>> For Each m1 In Application.CommandBars(1).Controls
>> For Each m2 In m1.Controls
>> If m2.Caption = "Hyperl&ink..." Then
>> m2.Enabled = False
>> End If
>> Next m2
>> Next m1
>>
>> Can anyone please explain to me why these methods fail to disable the
>> Hyperlink menu item, and if there is a way to do it?
>>
>> Thanks and regards
>>
>> Murray
>>

>
>

 
Reply With Quote
 
Murray
Guest
Posts: n/a
 
      28th Feb 2007
On Feb 28, 4:52 pm, "NickHK" <TungChe...@Invalid.com> wrote:
> Murray,
> With the addition of the missing " at the end of "Hyperl&ink...", it worked
> from the Immediate window:
>
> CommandBars("Worksheet Menu
> Bar").Controls("Insert").Controls("Hyperl&ink...").Enabled = False
> There is also:
> CommandBars("Cell").Controls("Hyperl&ink...").Enabled = False
> which appears on the right-click menu of a cell.
>
> NickHK
>
> "Murray" <myall_bl...@hotmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Greetings

>
> > The following piece of code works fine:

>
> > CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save
> > &As...").Enabled = False

>
> > However, if I change it to try and disable the Hyperlink menu item, it
> > will not work:

>
> > CommandBars("Worksheet Menu
> > Bar").Controls("Insert").Controls("Hyperl&ink...).Enabled = False

>
> > I then attempted to do it by brute force with equal lack of success:

>
> > For Each m1 In Application.CommandBars(1).Controls
> > For Each m2 In m1.Controls
> > If m2.Caption = "Hyperl&ink..." Then
> > m2.Enabled = False
> > End If
> > Next m2
> > Next m1

>
> > Can anyone please explain to me why these methods fail to disable the
> > Hyperlink menu item, and if there is a way to do it?

>
> > Thanks and regards

>
> > Murray- Hide quoted text -

>
> - Show quoted text -


Doh....

I can't believe I mucked around with this for about two hours
yesterday for something so simple.

Thanks NickHK for your help. Ron - thanks also for your reply and
suggestion.

Regards

Murray

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007+AnalysisServices2005SP2: Pivot Table to SSAS why menu item "Options"->"Formulas" is disabled? vimas Microsoft Excel Discussion 0 2nd Mar 2007 03:44 PM
- Excel 2007: Pivot Table to SSAS why menu item "Options"->"Formulas" is disabled? vimas Microsoft Excel Discussion 0 26th Feb 2007 07:56 PM
Excel 2007: Pivot Table to SSAS why menu item "Options"->"Formulas" is disabled? vimas Microsoft Excel Discussion 0 21st Feb 2007 04:35 PM
How to disable the "Insert Copied Cells" context menu item =?Utf-8?B?Q29lbg==?= Microsoft Excel Programming 21 9th Feb 2005 09:37 PM
How to restrict / disable "File", "Edit" and "View"-Menu?? =?Utf-8?B?bWFya3VzMzU0?= Windows XP Internet Explorer 2 4th Jun 2004 09:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:02 AM.