请教大侠们一个问题,这个问题快憋死我了,关于.Net调用Word的问题

lovelyxinxin 2005-03-15 10:49:55
我在.Net中为Word添加了一个工具条,工具条上的按钮一般用OnAction来执行宏,但是我想让按钮来执行.Net的指令,可以么?如
bool IsThisCommandBarExisted = false;
foreach (Office.CommandBar bar in Application.CommandBars)
{
if (bar.Name == StaticVarDecoration.CommandBarName)
{
IsThisCommandBarExisted = true;
}
}

if (IsThisCommandBarExisted == false)
{
Office.CommandBar bar = Application.CommandBars.Add(StaticVarDecoration.CommandBarName,
Missing.Value,
Missing.Value,
Missing.Value);
Office.CommandBarButton button = (Office.CommandBarButton)bar.Controls.Add(
Office.MsoControlType.msoControlButton,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value);
button.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;
button.Enabled = true;
button.Caption = "Test";

--->button.OnAction = "MessageBox.Show (\" Hello World\") ;"; //一般是调用宏的,但是我想达到这个效果,请问我该如何作那
ThisDocument.
bar.Visible = true;
}
...全文
105 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
CWYCN 2005-03-15
  • 打赏
  • 举报
回复
UP
doubon 2005-03-15
  • 打赏
  • 举报
回复
顶!
eArt 2005-03-15
  • 打赏
  • 举报
回复
mark study

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧