Customising the Ribbon in 2007

N

Nigel

Is there a way/how do I do it to customise the ribbon in Access 2007, as you
can it previous vewrsions to customise toolbars and menus.

Thanks
 
P

Paul

Hi Albert,

I saw this post and it looked like just what I needed:
http://msdn.microsoft.com/en-us/library/bb187398.aspx

I just can't get it to work.

Function BR_GetImages(control As IRibbonControl, ByRef image)
Static frmRibbonImages As Form_USysRibbonImages
Static rsForm As DAO.Recordset2

If frmRibbonImages Is Nothing Then
DoCmd.OpenForm "USysRibbonImages", WindowMode:=acHidden
Set frmRibbonImages = Forms("USysRibbonImages")
Set rsForm = frmRibbonImages.RecordsetClone
End If

rsForm.FindFirst "ControlID='" & control.Id & "'"
If rsForm.NoMatch Then
' No image found
Set image = Nothing
Else
Set image = frmRibbonImages.Images.PictureDisp
End If
End Function

I keep getting an Invalid Picture error on
Set image = frmRibbonImages.Images.PictureDisp

When I dig (and it has been some time) into this I don't understand how it
could ever work. I must be missing something? Images is an Attachment control
on the USysRibbonImages form, as far I can tell the Attachment object has no
member PictureDisp?

Any direction would be greatly appreciated.
Thanks!
Paul
 
A

Albert D. Kallal

I do not like that example at all..

The logic simply means you are opening a form in hidden mode, and the MOVING
THE RECORD to the correct position (and, the form will then display the
image from the recordset in an image control..and then you grab that image
from the form, and then close the form. Hardly a reasonable way to get a
simple image in a production environment. When I think about this, it means
that a ribbon to display one little image for a button would be opening a
WHOLE form to grab *ONE* simple image.

(I guess I saying I really don't like that code example one bit).
Set rsForm = frmRibbonImages.RecordsetClone

You can't use the RecordSetClone, you MUST use RecordSet. Remember,
reocrdsetclone moves independent of the form. When you use recordset, then
when you do a move/find etc, then the form actually MOVES WITH your
reocrdset. The example code has the above written as reocrdset, and NOT
recordsetclone. The reason for this is you MUST MOVE the form to the correct
record so the form can "render" the image on a image control on that form
(then your code is then going go "pluck" that image from the image control
on
the form).
When I dig (and it has been some time) into this I don't understand how it
could ever work. I must be missing something? Images is an Attachment
control
on the USysRibbonImages form, as far I can tell the Attachment object has
no
member PictureDisp?

I not looked, but if you don't have a image on the form, then you have to
add it...
Any direction would be greatly appreciated.

I would suggest that you consider placing the images in a directory
(relative) to your application. Or, we come up with a way to pull the image
directly out of a table. It just seem so kluge to launch a whole form and
then start navigating records in that form to the correct record to display
a
simple image for ONE control on a ribbon.
 
P

Paul

Albert, thank you so much for looking at this, I desperately need help.


Albert D. Kallal said:
I do not like that example at all..

The logic simply means you are opening a form in hidden mode, and the MOVING
THE RECORD to the correct position (and, the form will then display the
image from the recordset in an image control..and then you grab that image
from the form, and then close the form. Hardly a reasonable way to get a
simple image in a production environment. When I think about this, it means
that a ribbon to display one little image for a button would be opening a
WHOLE form to grab *ONE* simple image.

(I guess I saying I really don't like that code example one bit).
I couldn't agree with you more, but judging from its source, I have to
believe it at least works. Can you please explain how as developers we are
supposed to figure out how to load custom images if Microsoft provides
examples that don't work, I am mistified by this??? If nothing else, this
ribbon allows (apparently) you to load custom images, how is it done? I've
been scouring the internet and the best I can come up with is;

http://www.accessribbon.de/en/index...r_Defined_Icons___Pictures_In_Ribbon_Controls

The only way I can that to work is to use their LoadPictureGDIP method, it
will not work with the LoadPicture method? Moreover I was required to load
their basGDIP module which contains code with foreign language comments and
prompts, not really keen on doing that.
You can't use the RecordSetClone, you MUST use RecordSet. Remember,
reocrdsetclone moves independent of the form. When you use recordset, then
when you do a move/find etc, then the form actually MOVES WITH your
reocrdset. The example code has the above written as reocrdset, and NOT
recordsetclone. The reason for this is you MUST MOVE the form to the correct
record so the form can "render" the image on a image control on that form
(then your code is then going go "pluck" that image from the image control
on
the form).
I agree and understand. Being desperate to get this to work, I was just
trying anything and this happened to be the version I cut and pasted in the
post, sorry about that. Just to be clear, it still does not work using the
recordset.
I not looked, but if you don't have a image on the form, then you have to
add it...
Sorry I don't understand this comment. What is PictureDisp and what is its
parent object?
I would suggest that you consider placing the images in a directory
(relative) to your application. Or, we come up with a way to pull the image
directly out of a table. It just seem so kluge to launch a whole form and
then start navigating records in that form to the correct record to display
a
simple image for ONE control on a ribbon.

As I am writing this reply I am trying different things and I just had an
epiphany. I created my images (icons) with the A channel enabled (for
tranparency). This is why LoadPicture keeps saying 'Invalid Picture' :)
So I created one icon without the A channel to test this. Sure enough, no
error, but sadly the image did not show up in the ribbon? Solve one problem
and encounter another, the saga goes on :-(

Here is what I did get to this to work (not pretty):

Since the only way I can get my icons to load is to use the LoadPictureGDIP
method (not comfortable with this), I loaded the images in a table
attachment. When its time to load the ribbon, I copy the image from the table
to a file and use the LoadPictureGDIP method. This works, but seems like
another kluge, take it from a file, save it as an attachment in a table, read
the table and copy it back to file, read it and transfer to button. As you
said 'just to load one image in a button'.

There must be a better way, here the criteria:
1- Need to handle tranparency, otherwise the ribbon looks like hell. PNG
seems to be the best format.
2- Need to be able to store the images in a table. This makes so much sense;
-installation and maintnenance is greatly simplified
-no one can 'steal' your images

Thanks again and standing by.
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top