There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Visual Basic: How do I hide/disable menu bar item in Excel?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Lori713's Avatar
Member with 42 posts.
 
Join Date: Sep 2003
Location: Raleigh, NC
11-Nov-2003, 04:59 PM #1
Question VB: How do I hide/disable menu bar item in Excel?
I'd like to write a little VB code to hide a certain menu item (for instance, Save As) if certain conditions are met. It would look something like the following:

If myFlag = True Then
[hide/disable/gray out the Save As menu bar item]
End If

Visual Basic Help wasn't, well, helpful. I saw a lot about Command Bars, but no real examples of how to hide (enabled = false) them because I don't know the index nor the name(?) of the Save As menu item.

I tried the following to see if I could get it to tell me if "SaveAs" existed... but it bombs on the third line (some rude message about error 424 and an object being required... but I don't know the object name so... waaaahhh).

Sub HideSaveAs()
foundFlag = False
For Each CommandBarButton In CommandBars
If CommandBarButton.Name = "SaveAs" Then
CommandBarButton.Visible = False
foundFlag = True
End If
Next CommandBarButton
If Not foundFlag Then
MsgBox "The collection does not contain a SaveAsForms command bar."
End If
End Sub


Any ideas?

Thanks!

Lori

Last edited by Lori713 : 12-Nov-2003 10:20 AM.
Dynamo2000's Avatar
Member with 32 posts.
 
Join Date: Mar 2003
Location: Boston
12-Nov-2003, 04:21 AM #2
Lori, Just a thought, one strategy you might try is to use the Record Macro feature. Start this feature, do what you want (or at lease enuough of it to find the info you are after) and then stop the recording. Look at the code generated and wa la! Good luck!!!
__________________
And G-d said "Let there be light", and there was light. Couldn't/shouldn't G-d have said, Let there be peace, and then there would be peace?
Lori713's Avatar
Member with 42 posts.
 
Join Date: Sep 2003
Location: Raleigh, NC
12-Nov-2003, 09:09 AM #3
Thanks for the suggestion. Actually, I usually do that when I've got something repetitive that I can actually access through recording. Unfortunately, graying out (disabling) a menu bar item isn't one of those instances. Thanks anyways!
AlbertB's Avatar
Distinguished Member with 2,432 posts.
 
Join Date: Nov 2002
Location: Hampshire, UK
12-Nov-2003, 10:25 AM #4
Interesting one Lori.

I'm no expert on Excel or VB unfortunately, but coincidentally I was looking for an explanation of exactly the same thing. I saw it done in the "Minipops" quiz when I tried to cheat and steal the answers , and was curious as to how they could disable a few of the menu options.

I'll follow this one to see if it can be solved, and if I find anything myself I'll pass it on.

Have you thought of putting a similar post in the Business Applications forum so that the Excel experts can get a look?
__________________
1. "I make no personal claim to the truth, only the right to seek it, prove it in argument, and to be wrong many times in order to reach it."

2. "We have made a cage of words and placed our God inside, as boys trap a cricket, to make him sing for us alone."

Galileo Galilei
Lori713's Avatar
Member with 42 posts.
 
Join Date: Sep 2003
Location: Raleigh, NC
12-Nov-2003, 12:59 PM #5
I hadn't thought of cross-posting it to the Excel forum. I know I've seen it done before (a very long time ago), so as far as I know it's possible. Thanks!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:39 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.