Office中国论坛/Access中国论坛
标题:
access2010ADP中该怎样调用自定义Ribbon!
[打印本页]
作者:
XMX64311
时间:
2013-5-23 11:52
标题:
access2010ADP中该怎样调用自定义Ribbon!
我做了个登录窗体,登录成功后打开“主窗体”界面,并在主窗体的OPEN事件中增加了对自定义Ribbon的调用,可自定义Ribbon就出不来,不知道为什么?
作者:
tmtony
时间:
2013-5-23 13:06
要把程序传上来才好分析哦
作者:
XMX64311
时间:
2013-5-23 16:18
我传不上来,我把代码传上来请你看看,是以前一个老师的例子,我在ADP中总是不能调用,在access2010是好的,转成ADP就不行了!
1.模块:Ribbonloader
Sub 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, "USysRibbons")) Then
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
rs.MoveFirst
While Not rs.EOF
On Error Resume Next
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 Sub
2.表:USysRibbons
lngID RibbonName RibbonXml
3 AppRibbon "<customUI xmlns=""http://schemas.microsoft.com/office/2006/01/customui"">
<ribbon startFromScratch=""true"">
<tabs>
<tab id=""dbCustomTab"" label=""信息中心"" visible=""true"">
<group id=""dbCustomGroup"" label=""自定义组"">
<control idMso=""Paste"" label=""内置粘贴"" enabled=""true""/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>"
3.窗体:mainform
Private Sub Form_Open(Cancel As Integer)
loadRibbons
End Sub
作者:
zhuyiwen
时间:
2013-5-26 08:04
ADP 不支持DAO,因此没有 CurrentDb
作者:
XMX64311
时间:
2013-5-31 15:57
谢谢了
作者:
zhuyiwen
时间:
2013-6-11 12:07
这段程序应改为ADO访问:
Sub loadRibbons()
Dim i As Integer
Dim rs As ADODB.Recordset
Set rs = CurrentProject.Connection.Execute("SELECT * FROM dbo.USysRibbons")
Do While Not rs.EOF
Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
复制代码
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3