?
Solved

MS Access 2010 ribbon

Posted on 2013-05-16
12
Medium Priority
?
1,090 Views
Last Modified: 2013-05-27
Hello,
I would like to be able to disable / enable (in code) some of the built-in buttons, e.g. "Print" or "Quick Print" in my custom ribbon in MS Access 2010.

Example would be much appreciated.

Thanks!!
0
Comment
Question by:flsolo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
12 Comments
 
LVL 70

Expert Comment

by:KCTS
ID: 39173285
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39173330
The Q noted by KCTS is very long.
But at the end of it, you should have a very good idea of what's involved in customizing the Ribbon.

Now, your question was  
I would like to be able to disable / enable (in code) some of the built-in buttons, e.g. "Print" or "Quick Print" in my custom ribbon in MS Access 2010.

I wouldn't do that.  Since you've got a custom ribbon on the go, I'd populate it with buttons aimed at macros/code that do what YOU want.  That will give you the level of control that you want, without having to fight the system's built in tendency to think that it knows what's best.

A sample db from you would be most helpful.

Nick67
0
 

Author Comment

by:flsolo
ID: 39180640
Nick67,
Attached is the ms access db with all buttons on one ribbon. There is a button "Test 2" which works exactly as I need to - it is a custom button. I need to get working built-in buttons "Print" and "Quick Print" the same way, i.e. enable them when any report is shown and disable them when Form1 is shown.

Any help is appreciated.
Thank you.
Test2.zip
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Nick67
ID: 39184934
I'll have a look at it this evening, but
I need to get working built-in buttons "Print" and "Quick Print" the same way
will be ultimately self-defeating.  Those buttons will only work the way MS wants them to.  Your only simple choices are to hide built-in buttons, or display them and let them work the way MS intended.  While it may not be technically impossible to figure out which built-in button was pressed, cutoff its event at the knees, and substitute your own event, it's REALLY not going to be worth the effort
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39184985
If you REALLY have to have that kind of functionality, and have access to VSTO then you can take a gander at this
http://msdn.microsoft.com/en-us/library/vstudio/bb608623.aspx
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39186491
Alright here's a little jiggery-pokery of the Ribbon and BackStage
The Print and Quick Print look like they're MS's, but they are ours.
I am not at all sure that your events are working the way you desire, but I have put some msgboxes into them to show they are firing.  Control.tag seems to be empty, so nothing goes on.

I have hidden the BackStage, but it throws a one-time unhappy error when accessesd from an open form, whining about TabShare  The USysRibbons XML has been formatted for legibility.  You also have a control disabling problem when you close out a report--the Ribbon controls are NOT disabled until a new object is actually made the focus.

Let me know what you think.

Nick67
Nick1.accdb
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39186537
Alright,
That BackStage error existed in your original as well.
To get rid of it, look here
http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/c058c185-4076-4670-b7eb-b51100a10388

In Options | Client Settings turn off Show add-in user interface errors

Because the forms don't have a share tab, what you've done to pare down BackStage pops an error when a non-existent tab is made invisible.
0
 

Author Comment

by:flsolo
ID: 39187783
Nick67,
Thanks for noticing that error, it has never happened to me.

The database Nick1.accdb works the way I want (for enabling / disabling print and quick print buttons), but when the report is shown, print button enabled and clicked, I want to show the print dialogue. Is it possible? The same with quick print - when enabled and clicked it prints (the report) to the windows default printer.

Thanks!
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39188162
In Options | Client Settings turn off Show add-in user interface errors
From the look of the thread I posted, that option is set on a machine basis.  If it is off on your machine already, then you would have never seen the error.

The quick print should be  straight forward
DoCmd.OpenReport Screen.ActiveReport.Name, acViewNormal
ought to do it.

But if you liked the functionality behind those two print buttons, my customization of them was unnecessary.  You just need the Select Case True logic that I have set up to disable the MS buttons -- which is entirely doable.

You'd add the BackStage disablement XML to your existing USysRibbons so that no one can print from BackStage, and alter the Select Case True logic to point at the existing MS id's and not FakePrint and FakeQuickPrint

You could invoke a FileDialog object and its assorted rigamarole...but if you are perfectly happy with what MS's button does, why re-invent the wheel?
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39189756
Try this one
I think the buttons behave as you'd like
Nick1.accdb
0
 

Author Comment

by:flsolo
ID: 39199169
Nick67,
Thanks for your post again, yes the buttons works the way I want. You deserve the points already, but would you please show me (db example is the best) how to do it with standard MS buttons as mentioned in your last post (that was my original question)?

Thanks!
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 1600 total points
ID: 39199314
I did poke at that a bit...to learn that the MS buttons will NOT permit themselves to be disabled.  Apparently the idMSO bit in the XML tells the system to pointedly ignore anything the VBA code may tell it to do.

Ribbons are funny objects to manipulate with VBA.  The code doesn't behave the way you'd expect.  Putting breakpoints in the disablement code was useless.  The code would not stop for them.  Msgbox's worked, so you could see the code was firing, but the breakpoint would just be completely ignored.

You've got what you need--buttons that look like the MS ones but behave the way you want.
There is a listing of all the imageMso strings here
http://msdn.microsoft.com/en-us/library/dd953682(v=office.12).aspx
and a gallery of them here
http://soltechs.net/CustomUI/imageMso01.asp?gal=1&count=no
Which is certainly a lot more documentation than existed at the time that Q27231448 was posted.

So you should be able to mock up any MS button and make it behave how you want, which is certainly what the doctor ordered.  I think any effort to leave the idMso intact but then try to manipulate the resulting button will be wasted effort.

Nick67
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question