2016-04-13 42 views
1

我想從工作表中的列表中填充自定義Excel功能區中的dynamicMenu。我的xml代碼是這樣的:在excel UI Ribbon中動態填充dynamicMenu

<dynamicMenu id="A" label="Menu A" imageMso="FormatPainter" getContent="GetMenuContent" /> 

我可以看到菜單。我沒有的是GetMenuContent回調函數,但是我知道宏的填充菜單應該放在哪裏?

回答

1

解決!從this link得到了答案。

只是引導你的getContent指令,這個宏:

Sub GetContent(control As IRibbonControl, ByRef returnedVal) 
    Dim xml As String 

    xml = "<menu xmlns=""http://schemas.microsoft.com/office/2009/07/customui"">" & _ 
      "<button id=""but1"" imageMso=""Help"" label=""Help"" onAction=""HelpMacro""/>" & _ 
      "<button id=""but2"" imageMso=""FindDialog"" label=""Find"" onAction=""FindMacro""/>" & _ 
      "</menu>" 

    returnedVal = xml 
End Sub 

Sub HelpMacro(control As IRibbonControl) 
    MsgBox "Help macro" 
End Sub 

Sub FindMacro(control As IRibbonControl) 
    MsgBox "Find macro" 
End Sub