Image Buttons

Published 04 September 07 09:38 PM

This is the first installment in a series of posts about Access 2007 originally made by one of our developers on the Access team on his own blog that I'm moving here for the broader audience to enjoy. 

Up until this point, Access has supported command buttons with text or a picture, but never both at the same time. This has been a long standing request from users: the capability of showing both the caption and the picture. In Access 2007, you will notice a new property off of the command button called "Picture Caption Arrangement".

This property, which can be set to the following values:

  • No Picture Caption - This setting is the legacy behavior. If you have a caption specified, the button will show it. If you have a picture, only the picture will be shown;
  • General - The image will be shown to the left of the text (if you're in a left-to-right language, like English) or the right of the caption (if you're in a right-to-left language, like Hebrew);
  • Top/Bottom/Right/Left - The image will be shown in the specified arrangement: at the top, bottom, right or left of the caption (just pick one).

You will also notice that there is a new "Alignment" property. This property allows you to position the caption  and picture within the command button to the following settings (note this property can be used whether you have just a picture, just a caption, or both):

  • General - This is the legacy behavior. The image and caption will be positioned the left of the text (if you're in a left-to-right language, like English) or the right of the caption (if you're in a right-to-left language, like Hebrew);
  • Left/Center/Right - The image and caption will be positioned to the left, centered or to the right (just pick one);
  • Distribute - This is equivalent to the "justified" setting in Microsoft Word. The image and caption will be spaced out to fill out the command button.

With these two new properties (which are of course also available through the OM), you will now be able to create some cool looking command buttons without any label trickery needed. Since you can now use JPEGs, PNGs and other newer image formats with Access 2007, you can create some really impressive buttons.

For example, in the snapshot below I created three buttons using Windows Vista backgrounds as the pictures. I changed the buttons' back style to transparent and played with the alignment and picture caption alignment settings:

Image Buttons in Access 2007

Comments

# M. David Matney said on September 5, 2007 12:28 PM:

Can one of you guys do a white paper or start a thread on minimizing the ribbon.  I am not talking about the "startfromscratch" which only hides the ribbon if the ribbon is empty.

We have a Ribbon custom to our app, that always shows Maximized by default and it totally messes up the screen which is designed of 1024x768 - users are missing part of the screen because the Ribbon moves the screen down and thus off the visible area unless the ribbon is in a minimized state

On Application started we want to set an application option to minimize the ribbon.  I do not find any documentation anyplace on doing this except on VSTO site where they are using office.commandbars to determine the height of the ribbon and then based upon the height, they are minimizing it.  

That code example doesn't work for Access from what I understand cause there is no VSTO add-in for Access 2007

I am looking for something such as:

Application.CommandBars.minimized  = true

Or the equivilent code to accomplish the same thing so that upon application startup, we can set the initial state of the ribbon.

# grovelli said on September 5, 2007 2:14 PM:

Third of Five's blog was a right gem. I wonder what he's doing now...

# Zac Woodall said on September 5, 2007 7:07 PM:

David: Yeah, it would be good to do that.  Unfortunately there is no good programmatic way to collapse the ribbon.  I wish we had this.  The way customers mock it up today is by using sendkeys.

Grovelli: He's gone over to work on one of the Exchange teams, a great guy, and we're really going to miss him around here.  

# M. David Matney said on September 5, 2007 7:15 PM:

The problem is you cant just issue sendkeys ^F1 without checking to see if the ribbon is already minimized or not.  If you use sendkeys and its minimized, then it just maximizes it and thats defeating the purpose

Have to check for the state of the ribbon before you can issue sendkeys.  thanks to VSTO people.  I was able to get resolution.  

Heres the code for those that might have need for it

If Me.Application.CommandBars.Item("Ribbon").Height = 150 Then

   SendKeys "^{F1}", False

End If

Biggest problem was finding the documentation on what the Item Name was in the collection. Access 2007 is seriously lacking in documentation.  

Hopefully you guys will not only provide a better way to minimize the ribbon then sendkeys but also work on documenting these things. Even those at utter access couldn't figure this one out and had to have someone at VSTO msdn web site document it

# Zac Woodall said on September 6, 2007 10:17 AM:

Thanks for the feedback on this David.  The Access team doesn't actually have the ability to make  any changes here, but I'll pass your comments on to the shared Office team who is responsible for the ribbon in all apps.

# wedqthkphj said on September 6, 2007 4:59 PM:

Hello! Good Site! Thanks you! jrynryikys

# Oli-S said on September 7, 2007 11:24 PM:

"Even those at utter access couldn't figure this one out"

Actually I think we pointed you on the track you ended up using:

http://www.utteraccess.com/forums/showflat.php?Cat=&Board=91&Number=1494069&Zf=&Zw=ribbon&Zg=0&Zl=a&Main=1493982&Search=true&where=&Zu=64822&Zd=l&Zn=&Zt=6b&Zs=b&Zy=#Post1494069&Zp=

# M. David Matney said on September 8, 2007 12:46 AM:

The point made at utteraccess didn't resolve the issue.  sendkeys was not ever a question or issue for resolution.  The problem posed was how to obtain the ribbon height because issuing sendkeys without knowing the ribbon is pointless.  I already knew I could use sendkeys 50% of the time.  (binary is not monocular)

# M. David Matney said on September 8, 2007 12:51 AM:

Also, didnt you recommend at Utter Access to use "StartFromScratch" which as pointed out in that blog will not work, and is nothing related to what I ended up using.  Read above posts so you can see the code example I provide.  This has nothing to do with startfromscratch

New Comments to this post are disabled

About Zac Woodall

Zac is a Program Manager at Microsoft on the team designing Access’s next generation platform infrastructure. He advocates easy to use designs, organizes community efforts, and is the author of The Rational Guide to Microsoft® Office Access 2007 Templates. Zac has been working at Microsoft Corporation since 1999. Before that time, he attended the University of Idaho, from which he holds a B.S. in Computer Science.
Page view tracker