我有几个宏可以完成相同的操作:每个宏都打开一个单独的文件。我通过定制功能区上的控件激活了它们。但不是有几个宏是这样的:确定从宏(MS Word VBA)中点击了哪个功能区控件
ChangeFileOpenDirectory SeriesPath
Documents.Open FileName:="Doc1.docx", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:=Password$, PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto, XMLTransform:=""
,但只有文件名改变,我想有一个宏可以根据点击了哪个色带元素打开任何一个文件。问题是,我需要知道被点击的功能区元素的ID。我已经浏览过几个网站,都建议使用IRibbonUI.ID属性,但是当我尝试这样做时,我从Word中收到一条错误消息:“运行时错误91:对象变量或未设置块变量。
下面是我的带状导出XML代码的样本:
<mso:button idQ="x1:Open_00_1_549FAC6" label="00" imageMso="BlackAndWhiteDontShow" onAction="Open_00" visible="true"/>
<mso:button idQ="x1:Open_01_10_549FAC6" label="01" imageMso="AppointmentColor0" onAction="Open_01" visible="true"/>
<mso:button idQ="x1:Open_02_9_549FAC6" label="02" imageMso="AppointmentColor1" onAction="Open_02" visible="true"/>
<mso:button idQ="x1:Open_03_8_549FAC6" label="03" imageMso="AppointmentColor2" onAction="Open_03" visible="true"/>
有谁知道我做错了吗?
http://stackoverflow.com/questions/6026895/custom-ribbon-onaction-syntax-question –
向我们展示您的VBA代码,请,并注明该行触发错误。我怀疑是因为你对这个问题非常深刻,这是一个让你感到沮丧的小事。点击问题下方的“编辑”链接以添加代码。 –
我有同样的问题。看看https://stackoverflow.com/questions/46430800/how-disable-customui-buttons-in-ms-word-via-vba。你解决了吗? – user3676571