PC Review


Reply
Thread Tools Rate Thread

commandbar question

 
 
Mark Andrews
Guest
Posts: n/a
 
      3rd Nov 2008
I am trying to hide all menus except one custom menu.

This code hides all menus:

Public Function HideAllMenus()
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i
End Function

This was my first attempt (it does not compile):
I get an error on the "Dim cbarMenu as CommandBar" line (user defined type
not defined). I have references to Microsft Access 11 object library
MSACC.OLB.

Public Function HideAllMenus()
'Hides all menus except RPTMenu

Dim i As Integer
Dim cbarMenu As CommandBar

For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

Set cbarMenu = CommandBars("RPTMenu")
cbarMenu.Enabled = True

End Function


Help,
Mark


 
Reply With Quote
 
 
 
 
Daniel Pineault
Guest
Posts: n/a
 
      3rd Nov 2008
Firstly, you could use the Tools-Startup and then uncheck whichever toolbars
you wish to disable.

Alternatly, take a look at the following links as they cover this subject
with various approaches.

http://www.access-programmers.co.uk/...ad.php?t=97578
http://www.tek-tips.com/viewthread.c...1499473&page=1

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Mark Andrews" wrote:

> I am trying to hide all menus except one custom menu.
>
> This code hides all menus:
>
> Public Function HideAllMenus()
> Dim i As Integer
> For i = 1 To CommandBars.Count
> CommandBars(i).Enabled = False
> Next i
> End Function
>
> This was my first attempt (it does not compile):
> I get an error on the "Dim cbarMenu as CommandBar" line (user defined type
> not defined). I have references to Microsft Access 11 object library
> MSACC.OLB.
>
> Public Function HideAllMenus()
> 'Hides all menus except RPTMenu
>
> Dim i As Integer
> Dim cbarMenu As CommandBar
>
> For i = 1 To CommandBars.Count
> CommandBars(i).Enabled = False
> Next i
>
> Set cbarMenu = CommandBars("RPTMenu")
> cbarMenu.Enabled = True
>
> End Function
>
>
> Help,
> Mark
>
>
>

 
Reply With Quote
 
Mark Andrews
Guest
Posts: n/a
 
      3rd Nov 2008
On both of these responses:

1. That's where I got the code to begin with.
2. I already have a reference to Microsft Access 11 object library MSACC.OLB

Note: The code to disable all commandbars works fine.

However adding a line:
Dim cbarMenu As CommandBar

will cause it to not compile.

I did notice some of the articles saying the Microsoft Access 11 object
library should reference a DLL where mine references "MSACC.OLB"

I'm guessing it is some kind of reference issue. I had reference issues
after installing Access2007 and had to uninstall it to get Access2003
working again.

Any further help you could provide???

Thanks in advance,
Mark




"Chris O'C via AccessMonster.com" <u29189@uwe> wrote in message
news:8ca78d9fd49e9@uwe...
> The commmandbars class is part of the office library. Add Microsoft
> Office
> xx.0 Object Library to your list of references and recompile. xx.0 is the
> version of office you have installed on your pc.
>
> Chris
> Microsoft MVP
>
>
> Mark Andrews wrote:
>>I am trying to hide all menus except one custom menu.
>>
>>This code hides all menus:
>>
>>Public Function HideAllMenus()
>> Dim i As Integer
>> For i = 1 To CommandBars.Count
>> CommandBars(i).Enabled = False
>> Next i
>>End Function
>>
>>This was my first attempt (it does not compile):
>>I get an error on the "Dim cbarMenu as CommandBar" line (user defined type
>>not defined). I have references to Microsft Access 11 object library
>>MSACC.OLB.
>>
>>Public Function HideAllMenus()
>>'Hides all menus except RPTMenu
>>
>> Dim i As Integer
>> Dim cbarMenu As CommandBar
>>
>> For i = 1 To CommandBars.Count
>> CommandBars(i).Enabled = False
>> Next i
>>
>> Set cbarMenu = CommandBars("RPTMenu")
>> cbarMenu.Enabled = True
>>
>>End Function

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...ccess/200811/1
>



 
Reply With Quote
 
Mark Andrews
Guest
Posts: n/a
 
      4th Nov 2008
Chris,

Thanks for pointing out my lack of attention to detail!

That made everything work perfectly!

I guess I had it in my mind that since the commandbars collection worked
that it was something about the
Microsoft "Access" 11.0 Object library that was screwed up on my machine
(since an individual Commandbar
would not work).

Thanks again,
Mark

"Chris O'C via AccessMonster.com" <u29189@uwe> wrote in message
news:8cab5b0ef3381@uwe...
> You're right, it's a referenct issue. It's not working for you because
> you're mistaking the Access object library for the office object library.
> That's a different file.
>
> You need to add the Microsoft Office 11.0 Object Library to your
> references.
> Note the word "office" isn't the same as "Access" above.
>
> Chris
> Microsoft MVP
>
>
> Mark Andrews wrote:
>>On both of these responses:
>>
>>1. That's where I got the code to begin with.
>>2. I already have a reference to Microsft Access 11 object library
>>MSACC.OLB
>>
>>Note: The code to disable all commandbars works fine.
>>
>>However adding a line:
>>Dim cbarMenu As CommandBar
>>
>>will cause it to not compile.
>>
>>I did notice some of the articles saying the Microsoft Access 11 object
>>library should reference a DLL where mine references "MSACC.OLB"
>>
>>I'm guessing it is some kind of reference issue. I had reference issues
>>after installing Access2007 and had to uninstall it to get Access2003
>>working again.
>>
>>Any further help you could provide???

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...ccess/200811/1
>



 
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
Commandbar question Mark Andrews Microsoft Access 1 16th Feb 2009 10:09 PM
Context Menu Commandbar Question Sandusky Microsoft Excel Programming 3 4th Oct 2007 08:06 PM
Context Menu Commandbar Question Sandusky Microsoft Excel Programming 0 4th Oct 2007 06:36 PM
cant dim as commandbar =?Utf-8?B?U2VyZW4=?= Microsoft Excel Programming 1 21st Dec 2005 09:18 PM
CommandBar problem - Question Les Stout Microsoft Excel Programming 10 16th Nov 2005 12:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:03 PM.