配置我的功能区时遇到一些问题 1.只有宏作为onAction或getPressed属性工作。标准模块中的功能不起作用。用标准模块编写的回调也不起作用 2.如何在VBA函数中使用编辑框的值?
这是我的功能区的xml,例如:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab idMso="TabHome">
<group idMso="GroupFont" visible="false" />
</tab>
<tab id="CustomTab" label="Клиенты">
<group id="PeopleGroup" label="Люди">
<toggleButton id="ToggleButton1" size="large"
label="Все люди"
onAction="Pplopenmacro" imageMso="ContactPictureMenu"/>
<editBox id="PeopleEditBox"
label="Поиск по рег№"
onChange="MyEditBoxCallbackOnChange" />
<button id="Button3" label="TEST"
size="normal" onAction="=Person_choose()" />
</group>
<group id="CompaniesGroup" label="Компании">
<toggleButton id="ToggleButton2" size="large"
label="Компании"
onAction="Cmpnopenmacro" imageMso="MeetingsWorkspace" />
</group>
</tab>
<tab id="CustomTab2" label="Документы">
<group id="MyGroup" label="Документы" >
<button id="Button1" label="Счета"
size="large" onAction="Invoiceopenmacro" imageMso="BusinessFormWizard" />
<button id="Button2" label="Хуета"
size="normal" />
</group >
</tab>
</tabs>
</ribbon>
</customUI>
这些是我在std模块中的功能:
Public Sub MyEditBoxCallbackgetText(control As IRibbonControl, ByRef strText)
' Callback EditBox
' Select Case control.Id
' Case "PeopleEditBox"
' strText = "Hello World"
' End Select
MsgBox "1"
End Sub
Public Sub MyEditBoxCallbackOnChange(control As IRibbonControl, strText As String)
' Callback Editbox: Returnvalue Editbox
' Select Case control.Id
' Case "PeopleEditBox"
' MsgBox "Value Editbox: " & _
' strText, vbInformation, "Sample EditBox"
' End Select
MsgBox "2"
End Sub
Public Sub Person_choose()
'DoCmd.openForm "People", acNormal
MsgBox "Yahoo!"
End Sub
答案 0 :(得分:2)
您可能需要告诉XML可以找到该过程的位置。示例 -
<group id="PeopleGroup" label="People">
<toggleButton id="ToggleButton1" size="large"
label="All People"
onAction="ThisWorkbook.Pplopenmacro" imageMso="ContactPictureMenu"/>
<editBox id="PeopleEditBox"
label="Search by Region #"
onChange="ThisWorkbook.MyEditBoxCallbackOnChange" />
<button id="Button3" label="TEST"
size="normal" onAction="ThisWorkbook.Person_choose()" />
</group>
ThisWorkbook.
表示可以在ThisWorkbook
对象中找到这些过程(请参阅VBA编辑窗口中的Project Explorer)
我从来没有把回调放到标准模块中,但是既然你这样做了,你可能需要在XML中使用onAction="MyModuleName.Pplopenmacro"
这样的东西吗?