|
现在正在学习UIRIBBON,碰到错误,根据网上给的例子正在实践。但出现了错误,对于UIRIBBON还未完全明白。出现以下的错误描述:
“错误代码 0x80004005
根据DTD/架构,元素'{http://schemas.microsoft.com/office/2006/01/customui}customUI'的上下文中不允许使用文本。”
“要求:{http://schemas.microsoft.com/office/2006/01/customui}commands,{http://schemas.microsoft.com/office/2006/01/customui}ribbon。”
我看过了,错误应该是在模块的代码里面。模块代码如下
- Option Compare Database
- Function CreateFormButtons()
- Dim xml As String
- xml = _
- "<customUI xmlns=""http://schemas.microsoft.com/" & _
- "office/2006/01/customui"">" & vbCrLf & _
- " <ribbon startFromScratch=""false"">" & vbCrLf & _
- " <tabs>" & vbCrLf & _
- " <tab id=""DemoTab"" label=""LoadCustomUI Demo"">" & _
- vbCrLf & _
- " <group id=""loadFormsGroup"" label=""Load Forms"">" & _
- vbCrLf & _
- "{0}" & vbCrLf & _
- " </group>" & vbCrLf & _
- " </tab>" & vbCrLf & _
- " </tabs>" & vbCrLf & _
- " </ribbon>" & vbCrLf & _
- "</customUI>"
- Dim template As String
- template = "<button id=""load{0}Button"" " & _
- "label=""Load {0}"" onAction=""HandleOnAction"" " & _
- "tag=""{0}""/>" & vbCrLf
- Dim formContent As String
- Dim frm As AccessObject
- For Each frm In CurrentProject.AllForms
- formContent = formContent & _
- Replace(template, "{0}", frm.Name)
- Next frm
- xml = Replace(xml, "{0}", formContent)
- Debug.Print xml
- On Error Resume Next
- ' 如果从AutoExec宏中调用这段代码,
- ' 如果在USysRibbons表中有一个使用相同名称的定制
- ' 则会失败
- Application.LoadCustomUI "FormNames", xml
- End Function
- Public Sub HandleOnAction(control As IRibbonControl)
- ' 装载指定的窗体
- ' 设置其RibbonName属性以便显示自定义UI.
- DoCmd.OpenForm control.Tag
- Forms(control.Tag).RibbonName = "FormNames"
- End Sub
复制代码 |
|