473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to add the ribbon name with vba to the startup form

547 512MB
I would like to add the ribbon name using vba in my startup form. Is it possible

i have tried

Expand|Select|Wrap|Line Numbers
  1. 'Dim db As DAO.Database
  2. Dim rs As DAO.Recordset
  3. Dim RibbonName As String
  4. Set db = CurrentDb
  5. Set rs = db.OpenRecordset("usysribbons", dbOpenDynaset)
  6. RibbonName = "start2"
  7. Set db = Nothing
  8.  
any suggestions?
Nov 3 '13 #1

✓ answered by ADezii

That appears to be the correct sequence to me. The important point is that
when the Application is started, the LoadCustomUI method is automatically executed and all of the Custom Ribbons are made available to the Application.

5 7256
ADezii
8,834 Expert 8TB
It is a little more complicated than that.
  1. To create and make the Ribbon available to Access, you first create a Module in the Database with a Procedure that calls the LoadCustomUI Method, passing to it a Ribbon Name and the well-formed XML. You can use any Table for this Procedure. You can make different Ribbons available by using multiple calls to the LoadCustomUI method, passing in different XML as long as the name of each Ribbon and the ID attribute of the tabs that make up the Ribbon are unique. After the procedure is complete, you then create an AutoExec macro that calls the Procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom Ribbons are made available to the Application.
  2. Sample Code executed via AutoExec Macro:
    Expand|Select|Wrap|Line Numbers
    1. Function LoadRibbons()
    2. Dim db As DAO.Database
    3. Dim rs As DAO.Recordset
    4.  
    5. Set db = Application.CurrentDb
    6. Set rs = CurrentDb.OpenRecordset("tblRibbons")
    7.  
    8. '[RibbonName] - {TEXT}
    9. '[RibbonXml] - {MEMO}
    10.  
    11. Do While Not rs.EOF
    12.   Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXML").Value
    13.     rs.MoveNext
    14. Loop
    15.  
    16. rs.Close
    17. Set rs = Nothing
    18. Set db = Nothing
    19. End Function
  3. Once the Custom Ribbons are loaded, assign to Form:
    Expand|Select|Wrap|Line Numbers
    1. Me.RibbonName = "Some Ribbon"
Nov 4 '13 #2
MikeTheBike
639 Expert 512MB
Hi ADezii

Is there any reason why this method of creating a Ribbon for use in the Application is better than defining the Ribbon in USysRibbons table?

MTB
Nov 4 '13 #3
ADezii
8,834 Expert 8TB
I think that the only advantage to this approach, MikeTheBike, is that Ribbons need not be defined solely within the context of the UsysRibbons Table. The XML Markup can come from a Recordset Object created from a Table, from a source external to the Database (such as an XML file that you must parse into a String), or from XML markup embedded directly inside of the procedure.
Nov 4 '13 #4
neelsfer
547 512MB
thx adezii for the trouble.
As i understand it, i first create a new table ie "tblRibbons", and add 2 fields called "RibbonName" and "RibbonXml" , add my "ribbon code" and "titles" to the fields, then call the module from my startup form?
Nov 4 '13 #5
ADezii
8,834 Expert 8TB
That appears to be the correct sequence to me. The important point is that
when the Application is started, the LoadCustomUI method is automatically executed and all of the Custom Ribbons are made available to the Application.
Nov 4 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Imayakumar | last post by:
Hi, I got two forms, named Form1 and Form2 ion a VB.NET Windows application.. by default if i run the application, Form1 gets launched..i need to set Form2 as the startup form how do i do it??...
1
by: John Michael | last post by:
I have created some password routines to protect certain forms from access without a password. This allows me to create some security for apps that will be used on diff machines for users that...
10
by: PC Datasheet | last post by:
How can I programatically set the startup form when the database opens? Thanks! Steve
4
by: Chris Ashley | last post by:
I have a class called App set as the startup object with the following code: Friend Class App Shared Sub Main() Dim FrmMain As New MainForm Application.Run(FrmMain) End Sub End Class In...
6
by: Steve Enzer | last post by:
My project uses a MDI parent form and several child forms. I need to call a public sub in the parent form (which is also the startup object) from one of the child forms in order to change the...
4
by: Johnnie Miami | last post by:
I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified as the startup form. If the user is successful logging in, I call my main form (main.vb). This all works fine but the...
10
by: Bernie Hunt | last post by:
This is probably a silly question, but I've gotten myself confused. My app has two forms, form1 and form2. form1 is the start up object in the propers. An event in form1 instantiates form2. ...
2
by: Glyn | last post by:
Hi All, Access 2000 SR1 Windows XP SP2 Word 2000 I have a button on a form (frmMainMenu) that calls a second form (frmContractPrint). In the second form is a combo box (cboContractNumber)...
2
by: Akinyemi | last post by:
I am developing a Payroll Program. I would like the Startup Form of the Program to show an image/icon representing an employee with the actual name of an employee under it or by its side just like...
4
by: AndrewMastKY | last post by:
I'm using Windows 8, but had the same problem occur in XP with Access 2003. MDB is located on a 2008 Server with HyperV. For the past month I have been struggling to resolve this issue or even...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.