I've been able to load my custom ribbon via the autoexec macro, and it works
when I apply it to the current database via using the Access options screen.
It also works when applied via code to a form. But is there a way to
programatically change it at the application level so that it applies to all
forms? Something like an Application.Ribbon property?
Not 100% sure I follow your queston? If you set the ribbon in the options
for current database, then that ribbon will apply to all forms.
However, if you have a few forms that need to display/show a dffernt ribbon,
then simply specify the name of that ribbon in the forms "other" property.
You quite much should use the forms property, because then if you have two
or three different forms opened, and each of those forms is to have a
different ribbon, it becomes next to impossible from a coding point of view
to try and start managing all this code yourself that's supposed to know
what ribbon to display at the correct time when a user switches between
different forms.
If you set the ribbon for a form, then access handles all of this changing
of the ribbon for you automatically when the focus changes between different
forms.
You can certainly specified the ribbon that loads in your startup code/form.
Once that ribbon is loaded, then it going to be application level.
You use the command LoadcustomUI in VBA. You can check out this command in
the help. Just remember to give the actual ribbon name you're going to load
the same as what you've specified in the access "Current database" options.
it's not clear if you're trying to change the room and that displays for
different users when they launch the application, or you simply won a
different ribbon for you the developer and what your users see?
However if you just wanting to display different ribbons for different forms
that are loaded, then I suggest you just use the ribbons property in the
form's other tab of the property sheet as this turns out to be less coding.
On the other hand if there's just a few different options that you want to
enabled or disabled to display for particular users, then I suggest that you
use code to "disable" or "enable" the particular options on your custom
ribbon. This is less work in the long run and it saves you from having to
maintains several copies of what essentially should be the same ribbon just
because you have a couple of options that are to be enabled, or disabled.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOO...@msn.com
Thanks for your response. I realize that the application level ribbon can
be set in the options. But is there a way to do that via code instead?
We are getting ready to move from Office 2003 to Office 2007. We have about
40 Access applications that will all be using a specific custom ribbon. I'll
be pasting some code into our standard startup routine that loads a custom
ribbon. It would be nice to be able to just add a couple extra lines of code
to apply that ribbon at the application level instead of having to set each
individually in the options.
We can change most other application level settings via code. The ability
to interact with the ribbon object in a similar manner doesn't seem like such
an unusual expectation.
Add a call to InitApp to the autoexec macro. It checks the version of
Access and calls the LoadRibbon procedure if version 2007 or higher.
LoadRibbon, loads the blank (or custom) ribbon. Finally, it checks to see if
the current project property CustomRibbonID exists. If it doesn't, then it
adds it, otherwise it sets it to the name of the newly added custom ribbon.
Presto...no ribbon.
Public Function InitApp()
On Error GoTo Err_InitApp
' This function is called as the first action in the autoexec macro. If
the version of office is
' 2007 or higher, then it calls a procedure to load a custom ribbon.
' Important: The actual command to load the ribbon will generate an
error in office 2003. To prevent
' the error it must be in a separate procedure that only gets called for
office 2007.
If Application.Version >= 12 Then
LoadRibbon
End If
Exit_InitApp:
Exit Function
Err_InitApp:
MsgBox "Function=InitApp" & vbcrlf & "Err#=" & Err & " " & Error$
Resume Exit_InitApp
End Function
Public Sub LoadRibbon()
On Error GoTo Err_LoadRibbon
Dim S As String
Const RibbonName = "No_Ribbon"
Const RibbonProp = "CustomRibbonID"
' This is a custom ribbon defined in XML that removes as much of the
ribbon as possible
S = "<customUI
xmlns=""http://schemas.microsoft.com/office/2006/01/customui"">" & vbcrlf & _
" <ribbon startFromScratch=""true"">" & vbcrlf & _
" <officeMenu>" & vbcrlf & _
" <button idMso=""FileOpenDatabase"" visible=""false"" />"
& vbcrlf & _
" <button idMso=""FileNewDatabase"" visible=""false"" />" &
vbcrlf & _
" <button idMso=""FileCloseDatabase"" visible=""false"" />"
& vbcrlf & _
" </officeMenu>" & vbcrlf & _
" </ribbon>" & vbcrlf & _
"</customUI>"
' This actually loads the ribbon.
' Note: this command does not exist in Access 2003. Just having it in
a procedure called
' under Access 2003 will generate an error under 2003. Using an if
statement so it doesn't
' get executed will not help. It must be in a separate procedure where
the entire procedure
' is only called under 2007.
Application.LoadCustomUI RibbonName, S
' And this will apply the ribbon if it's not already set
If Not DoesPropertyExist(RibbonProp) Then
CurrentProject.Properties.Add RibbonProp, RibbonName
ElseIf CurrentProject.Properties.Item(RibbonProp) <> RibbonName Then
CurrentProject.Properties.Item(RibbonProp) = RibbonName
End If
Exit_LoadRibbon:
Exit Sub
Err_LoadRibbon:
MsgBox "Sub=LoadRibbon" & vbcrlf & "Err#=" & Err & " " & Error$
Resume Exit_LoadRibbon
End Sub
Private Function DoesPropertyExist(Name As String) As Boolean
' This just loops through the properties to see if the specified one
exists
Dim I As Integer
Dim RetVal As Boolean
RetVal = False
For I = 0 To CurrentProject.Properties.Count - 1
If CurrentProject.Properties.Item(I).Name = Name Then
RetVal = True
Exit For
End If
Next
DoesPropertyExist = RetVal
End Function
--
?
"gael" <carnac@yhlirelive> wrote in message
news:u8Wmf$3CKHA...@TK2MSFTNGP03.phx.gbl...
"gael" <carnac@yhlirelive> wrote in message
news:u8Wmf$3CKHA...@TK2MSFTNGP03.phx.gbl...
Incidentally, posting in upper case is the visual equivalent of shouting,
and is considered to be rude.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Cudz" <Cu...@discussions.microsoft.com> wrote in message
news:0EF1029D-6D96-4F61...@microsoft.com...
I too am anything but impressed with the "ribbon" in the new iteration of MS
Office.
Everyone in my office group, my peers and my family clearly understood how
to get their work done. Now I am overwhelmed with questions relating to the
"look" and "feel" regarding "Oh shoot... how do I do it now?" questions
which is taking away from those duties for which I am paid for and held
accountable to perform.
Let me put this tactfully. I am paying a fee for the privilege to use a
product you (Microsoft) designed which proportedly will make my life / job
easier. The inability to revert to the 2003 vintage GUIs at the USER lever
is NOT a benefit I am willing to pay anything for.
Regarding Cudz's opinions below. You suggest that his using upper case text
is rude yet Microsoft can turn its customer's GUI world upside down without
good reason then lend a deaf ear to their after-market concerns? Without
even the pretense of "oops.. sorry guys, we'll fix that right a way?" Just
so you know sir, I'm whispering...
You are not helping the situation by suggesting the user fix their GUI woes
theirself by sending us/them to third party vendors who, for a nominal fee,
will provide us lowly users a "cure" for your boo-boo... which we've already
paid a hefty price for to start with??? I expected better product
development and after-sales support from you guys than this. I am
disappointed.
You salted the stew. You eat it.
As for me and mine, we're off to see about a slice of Apple pie.
Rick Kritikos
Just a dumb old hic user...
"Douglas J. Steele" wrote:
> .
>
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Kriter01" <Krit...@discussions.microsoft.com> wrote in message
news:91EC197E-0191-48DD...@microsoft.com...