UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Build Ribbons in Ms access 2007 ADP    
 
   
inarobis
post May 7 2007, 12:17 PM
Post #1

New Member
Posts: 14



Hello,
would like to know if there is a restriction with ADP project Ms access 2007. I am having problem on build ribbons and others stuffs.
Could someone give me some information about this?
Inarobis
Go to the top of the page
 
+
robcooper
post May 10 2007, 09:17 PM
Post #2

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



Hi,
You can create ribbon customizations in ADP files in Access 2007 but Access does not load them automatically. As a result, you'll need to use the LoadCustomUI method on the Access Application object to load them using code.
Check out this article for more information.
Hope this helps,
Go to the top of the page
 
+
inarobis
post May 15 2007, 02:10 AM
Post #3

New Member
Posts: 14



thank you very much I will go throught this information.
It is the same if I woud like to hide ribbon in ADP access using code?
Ina
Go to the top of the page
 
+
robcooper
post May 15 2007, 10:29 AM
Post #4

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



You're welcome. Yes, the XML for the ribbon customization is the same for all file formats.
Go to the top of the page
 
+
Mac_85
post Feb 8 2009, 08:26 PM
Post #5

UtterAccess Enthusiast
Posts: 77
From: New Zealand



I have a table in SQL, named USysRibbons.
This has XML language that works in an ACCDB file
I have a module, RibbonLoader:
Function LoadRibbons()
Dim i As Integer
Dim db As DAO.Database
Set db = Application.CurrentDb

For i = 0 To (db.TableDefs.count - 1)
If (InStr(1, db.TableDefs(i).Name, "Ribbons")) Then
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
rs.MoveFirst
While Not rs.EOF
Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
End If
Next i
db.Close
Set db = Nothing
End Function
My AUTOEXEC macro calls the Function:
RunCode LoadRibbons()
When the db starts, I get the error message:
Action Failed
Error Number 2950.
The db is in a trusted location
Go to the top of the page
 
+
Mac_85
post Feb 11 2009, 10:32 PM
Post #6

UtterAccess Enthusiast
Posts: 77
From: New Zealand



I have a table in SQL, named USysRibbons.
This has XML language that works in an ACCDB file
I have a module, RibbonLoader:
CODE
Function LoadRibbons()
Dim i As Integer
Dim db As DAO.Database
Set db = Application.CurrentDb
For i = 0 To (db.TableDefs.count - 1)
If (InStr(1, db.TableDefs(i).Name, "Ribbons")) Then
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
rs.MoveFirst
While Not rs.EOF
Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
End If
Next i
db.Close
Set db = Nothing
End Function

My AUTOEXEC macro calls the Function:
RunCode LoadRibbons()
When the db starts, I get the error message:
Action Failed
Error Number 2950, even though the db is in a trusted location...
Would really like to get this to work, and any help would be appreciated!
Go to the top of the page
 
+
robcooper
post Feb 12 2009, 01:52 PM
Post #7

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



Are you using an ACCDB or ADP? Access will automatically load ribbons from the USysRibbons table. If you are using an ADP, the CurrentDb() function and other DAO objects like DAO.Recordset and DAO.TableDef are not available.
Go to the top of the page
 
+
Mac_85
post Feb 12 2009, 06:02 PM
Post #8

UtterAccess Enthusiast
Posts: 77
From: New Zealand



It's an ADP in Access 2007.
I've followed the instructions as outlined in the linked message for an ADP.
The autoexec macro calls the code, above, that query's the table to run this when the app starts - or I have mis-read something on the MSDN page?
Many thanks
Go to the top of the page
 
+
robcooper
post Feb 12 2009, 09:20 PM
Post #9

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



Unfortunately this code uses DAO so it will not work in an ADP. To get this to work in an ADP you'll need to use ADO. Will you try this code instead and call this routine from the autoexec macro? This code doesn't loop through all tables in the database so you'll need to change the name of the table that contains Ribbons as needed.
!--c1-->
CODE
Function LoadRibbonsADP()
    Dim rs As ADODB.Recordset
    Dim i  As Integer
    
    ' open the table containing ribbons.
    On Error GoTo LoadRibbonsADPErrors
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseServer
    rs.Open "SELECT * FROM <YourTableName>", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
    
    ' load the ribbons
    While Not rs.EOF
        Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value
        rs.MoveNext
    Wend
    
LoadRibbonsADPExit:
    If Not rs Is Nothing Then
        rs.Close
    End If
    Set rs = Nothing
    Exit Function
LoadRibbonsADPErrors:
    If Err = 32609 Then
        MsgBox "The specified ribbon is already loaded", vbExclamation
        Resume Next
    Else
        MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
        Resume LoadRibbonsADPExit
    End If
End Function

Hope this helps,
Go to the top of the page
 
+
Mac_85
post Feb 25 2009, 10:16 PM
Post #10

UtterAccess Enthusiast
Posts: 77
From: New Zealand



Using this code, the app at least opens without an error, but it does not load the custom Ribbon...
Go to the top of the page
 
+
robcooper
post Feb 26 2009, 11:53 AM
Post #11

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



This code only loads the ribbons so they can be used in the database. Have you already set the Ribbon Name property for the database in the Access Options dialog?
Go to the top of the page
 
+
Mac_85
post Mar 10 2009, 08:46 PM
Post #12

UtterAccess Enthusiast
Posts: 77
From: New Zealand



Yes I had - it turned out I had major issues with the XML code that had been created by a Ribbon Tool.
Oneeded to remove code that referenced modules the tool creates (even though having them in the Project, this still created errors).
nce I had the code correct - it was correctly loaded by Access.
Thanks for all your help!
Go to the top of the page
 
+
robcooper
post Mar 10 2009, 11:38 PM
Post #13

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



Wow, nice job narrowing that down. Glad you got it working.
ou've probably already seen this, but there is an option called "Show add-in user interface errors" in the Advanced page in the Access Options dialog that can also help find problems working with Ribbon XML.
Go to the top of the page
 
+
Mac_85
post Mar 11 2009, 07:11 PM
Post #14

UtterAccess Enthusiast
Posts: 77
From: New Zealand



Ah - didn't realise it would help with that. Thanks!
Go to the top of the page
 
+
robcooper
post Mar 11 2009, 08:14 PM
Post #15

Microsoft Corp UtterAccess VIP
Posts: 1,839
From: Bellevue, WA



You're welcome. Good luck!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 23rd October 2014 - 05:59 AM