Jason Jiang said:
Dear
I built a ribbon tab for a form. It works fine and when the form opening,
the ribbon will be loaded fine. But it would be focus (or active)
automatically. It still focus in the tab where I set now. Please
help.!!urgent.!!
I don't believe there is a way to do the above. The simply solution I use is
to create a whole new ribbon from scratch. and, I usually stick to one
"tab". You can have "several" groups display on the ribbon. so, presumably,
you would have your ribbon display + perhaps the filter + clipboard groups
(I don't see the need for much more).
I don't think it makes a lot of sense to load up a form, and add a new "tab"
to the existing ribbon..that going to either
a) fore the user to have to click on that tab (hence your question!)
b) if they do click on that tab, then they loose all the cut/past/filter
etc....
so, the solution so far is to simply load up a custom ribbon for form with
one tab....
Not the best solution but I don't believe there is a programme way to select
a tab right now...
I shall assume you know how to "look up" the names of other groups you want
to include in your ribbon.
So, right after your group (or, perhaps before makes more sense), you can
"steal" the existing groups you need, and *include* them in your custom
ribbon.
So,
<group idMso="GroupClipboard" />
<group idMso="GroupFindAccess" />
<group idMso="GroupSortAndFilter" />
The above is quite typcial of what you need (clipboard, find,
sorting/fitler). so, just include the above 3 with your ribbon...I not
likely the user needs all those other tabs anyway....
So, build your ribbon with the "start from scratch" = true:
eg:
<customUI xmlns="
http://schemas.microsoft.com/office/2006/01/customui"
onLoad="MyRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="Home" label="Home">
<group idMso="GroupClipboard" />
<group idMso="GroupFindAccess" />
<group idMso="GroupSortAndFilter" />
<group id="group1" label="group1">
<button id="button1" label="Buttion1"
getVisible="MyVisible"
getEnabled="MyEnable"
onAction="=MyTest1()" />
<button id="button2" label="button2" onAction="=Mytest2()"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
So, in the above, we place the built-in groups we need before our custom
group with the buttons.
So, we just specify the above ribbon in the "other" tab of the forms
property. In the above, I do have two call backs (getvisble, and
getenabled...and they MUST be in a standard module.
However, the function MyTest1() can be in either the form, or the standard
public module (this is the SAME as to how it worked before).
Another question:
is the callbacks for the ribbon always in Modules? I remember in Access
2003, the callbacks function could be in the form class modules. If all
the callbacks should be in the Modules, does it mean we need distinguish
which form or report is active now?
Don't confuse the code that a menubar runs. As mentioned calling the
"on-action" code works the same as it did before. The new ribbon/version HAS
NOT changed this. That means the "on-action" setting can call code in your
current form, or a standard module. (which ever form has the focus is
searched for the code...so, one ribbon can do different things when
different forms has the focus..since the code will be run from the form). If
the code is not found in the form with the focus..then standard modules are
searched for the function name.
However, the so called "call backs" are used to enable, and disable
controls, that code MUST be in a standard code module.
I have a working solution that automatic makes a control collection, so you
can much enable/disables controls like you did before...
I already posted the code in this newsgroup...but will put a web page with
the code ASAP....