Excel 在VBA中触发自定义功能区按钮单击

Excel 在VBA中触发自定义功能区按钮单击,excel,vba,Excel,Vba,在我的项目中,我用XML创建了一个excel功能区,如下所示 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="LoadRibbonImage" onLoad="onLoad" ><ribbon><tabs> <tab id="AddInTabId" label="MyCustomRibbon"> <group id="Conne

在我的项目中,我用XML创建了一个excel功能区,如下所示

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="LoadRibbonImage" onLoad="onLoad" ><ribbon><tabs> <tab id="AddInTabId" label="MyCustomRibbon">
<group id="Connections" label="Connections">
<button id="Config" label="Server Configuration" size="large" getEnabled="getEnabled" onAction="MyActionMethod" screentip="Server Configuration" image="Config.png" />
</group>
</tab></tabs></ribbon></customUI>

我不是百分之百确定这是否适合你,但也许你可以看看。它不会触发该按钮,但通过该按钮,您可以在Visual C#项目中向VBA公开代码。因此,基本上,VBA方法应该能够直接调用C#方法。(完全不用按钮)谢谢。我不确定这是否对你有用,但也许你可以看看。它不会触发该按钮,但通过该按钮,您可以在Visual C#项目中向VBA公开代码。因此,基本上,VBA方法应该能够直接调用C#方法。(完全不用按钮)谢谢。我会试试看。
Dim b As CommandBarButton
Set b = Application.CommandBars("AddInTabId").Controls("Config")
If (b.Enabled = True) Then
b.Execute
End If