CommandBarControl需要解释 [英] CommandBarControl need an explanation

查看:245
本文介绍了CommandBarControl需要解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
有人可以帮我这个代码吗?

Hi everyone,
Could someone help me with this code?

Dim cmdBar As Microsoft.Office.Core.CommandBarControl
Dim cmdBarButton As Microsoft.Office.Core.CommandBarButton


cmdBar = Globals.ThisAddIn.Application.CommandBars("Cell") _
.Controls.Add(Office.MsoControlType.msoControlPopup, , , 1, )


cmdBarButton = TryCast(cmdBar.Controls.add _(Office.MsoControlType.msoControlButton, , , 1, ), Microsoft.Office.Core.CommandBarButton)


这段代码有效,但是我不知道如何以及为什么,因为没有cmdBar对象的方法控件?

cmdBar.Controls
为什么会起作用,以及如何使其变得更好?
提前谢谢.

(此代码不是我自己编写的.)


This code is working, but however, I don''t understand how and why, because there is no Method Controls for cmdBar Object?

cmdBar.Controls
Why is it working and how to make it better?
Thanks in advance.

(This code is not written by myself.)

推荐答案

如果您使用的是Visual Studio,请在代码中使用Breakpoint来查找弄清楚代码每个阶段的作用.

检查MSDN: http://msdn.microsoft.com/zh-CN/library/ktf38f66(v = VS.90).aspx [ ^ ]
If you''re using Visual Studio, use Breakpoint in your code to find out what it''s doing on each phase of your code.

Check MSDN: http://msdn.microsoft.com/en-us/library/ktf38f66(v=VS.90).aspx[^]


可以在以下站点的此网站上找到解决方案:
The solution is found on this site here: http://msdn.microsoft.com/en-us/library/microsoft.office.core.commandbar_members(v=office.11).aspx[^].

Controls is not a method but rather a property of CommandBar.

Hope that clears it up for you!

Cheers,

-MRB


已解决:
Dim cmdBar As Microsoft.Office.Core.CommandBarPopup
Dim cmdBarButton As Microsoft.Office.Core.CommandBarButton


cmdBar = TryCast(Globals.ThisAddIn.Application.CommandBars("Cell").Controls.Add(Office.MsoControlType.msoControlPopup, , , , True), Office.CommandBarPopup)


cmdBarButton = TryCast(cmdBar.Controls.add(Office.MsoControlType.msoControlButton, , , 1, ), Microsoft.Office.Core.CommandBarButton)


这篇关于CommandBarControl需要解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆