Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Menu problem in Excel


Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Menu problem in Excel

Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Menu problem in Excel


Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Menu problem in Excel

Hi Amit

To many zero's
Use 30002 to test

But you must use the name

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False



--

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


"Amit" wrote in message oups.com...

Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Menu problem in Excel


I already had used the name but it didn't work! one thing is that I'm
trying to hide or disable the "My Menu" not sub-items.



Ron de Bruin wrote:
Hi Amit

To many zero's
Use 30002 to test

But you must use the name

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False



--

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


"Amit" wrote in message oups.com...

Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Menu problem in Excel

Where is "My Menu" ?
In the same row as File, Edit, ..................

--

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


"Amit" wrote in message ps.com...

I already had used the name but it didn't work! one thing is that I'm
trying to hide or disable the "My Menu" not sub-items.



Ron de Bruin wrote:
Hi Amit

To many zero's
Use 30002 to test

But you must use the name

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False



--

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


"Amit" wrote in message oups.com...

Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Menu problem in Excel


No, it is a made up menu by my code (VBA). It is located next to Help
menu. between Help and Window menus.




Ron de Bruin wrote:
Where is "My Menu" ?
In the same row as File, Edit, ..................

--

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


"Amit" wrote in message ps.com...

I already had used the name but it didn't work! one thing is that I'm
trying to hide or disable the "My Menu" not sub-items.



Ron de Bruin wrote:
Hi Amit

To many zero's
Use 30002 to test

But you must use the name

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False



--

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


"Amit" wrote in message oups.com...

Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Menu problem in Excel

Hi

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False

Then this will work
Be sure that the name is correct

I use 1 it this example but it the same as Worksheet Menu Bar
This example add a item and delete it

Sub MenuBar_Item()
On Error Resume Next
Application.CommandBars(1).Controls("Hi").Delete
On Error GoTo 0
With Application.CommandBars(1)
With .Controls.Add(Type:=msoControlButton, befo=1)
.Style = msoButtonCaption
.Caption = "&Hi"
.OnAction = ThisWorkbook.Name & "!TestMacro"
End With
End With
End Sub

Sub MenuBar_Item_Delete()
On Error Resume Next
Application.CommandBars(1).Controls("Hi").Delete
On Error GoTo 0
End Sub

Sub TestMacro()
MsgBox "Hi"
End Sub


--

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


"Amit" wrote in message ups.com...

No, it is a made up menu by my code (VBA). It is located next to Help
menu. between Help and Window menus.




Ron de Bruin wrote:
Where is "My Menu" ?
In the same row as File, Edit, ..................

--

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


"Amit" wrote in message ps.com...

I already had used the name but it didn't work! one thing is that I'm
trying to hide or disable the "My Menu" not sub-items.



Ron de Bruin wrote:
Hi Amit

To many zero's
Use 30002 to test

But you must use the name

Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Enabled = False



--

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


"Amit" wrote in message oups.com...

Hello Ron,

Thank you for your response. I followed your suggestion however, I'm
using

ThisWorkbook.Commandbars.FindControl(ID:=300002).E nabled = False just
to see how it works but I get error message:


Object variable or With block variable not set - error code 91

Any advice?

Thank you.
amit


Ron de Bruin wrote:
Hi Amit

If it is the Worksheet Menu Bar then this will not work
Look for a code examples on this page
http://www.rondebruin.nl/menuid.htm


--

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


"Amit" wrote in message ups.com...

Hello group,

I'm trying to hide a user-defined menu item in Menu bar during
following event:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.Commandbar("My Menu").Visible =
False
End Sub

Which causes run time error '91' or "Object variable or With block
variable not set"


Does anybody know how can fix this?

Your help will be appreciated.

Thanks,
akohan




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 problem michael.beckinsale Excel Programming 1 July 31st 06 11:54 AM
PRoblem with Menu Set up ExcelMonkey Excel Programming 4 October 4th 05 10:30 PM
Excel Menu Problem RONGGGG Excel Discussion (Misc queries) 4 June 13th 05 08:17 PM
MENU Problem tony moody Excel Programming 0 September 18th 04 05:32 PM
MENU Problem TAM Excel Programming 0 September 18th 04 03:00 PM


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