你的: for i:=1 to MSWord.commandbars.count do 应该改为: for i:=0 to MSWord.commandbars.count-1 do ————————————————————————————————— MaximStr := '宠辱不惊,看庭前花开花落,去留无意; 毁誉由人,望天上云卷云舒,聚散任风。'; if Not Assigned(I) then I := TI.Create(Nil); I.Maxim := MaximStr; I.Explain := '假如上述代码中出现“OA”等字样,删除它们'; I.Desire := '加不加分随你'; —————————————————————————————————
自动化对象不支持改变Commandbars[i].visable。 你可以将: for i:=1 to MSWord.commandbars.count do的循环值改小一点运行测试。 ————————————————————————————————— MaximStr := '宠辱不惊,看庭前花开花落,去留无意; 毁誉由人,望天上云卷云舒,聚散任风。'; if Not Assigned(I) then I := TI.Create(Nil); I.Maxim := MaximStr; I.Explain := '假如上述代码中出现“OA”等字样,删除它们'; I.Desire := '加不加分随你'; —————————————————————————————————
参考: if WordApplication1.CommandBars.ActiveMenuBar.Enabled then with WordApplication1.CommandBars.ActiveMenuBar do for i:=1 to Controls.Count do Controls[i].Set_Visible(false);
TO:xxmmmx(踢踏) 你的这段代码可以将代码菜单全部屏闭掉,但是显示菜单的工具条不能屏闭, 我加了一条代码,如下所示,但是运行出错, if WordApplication1.CommandBars.ActiveMenuBar.Enabled then with WordApplication1.CommandBars.ActiveMenuBar do for i:=1 to Controls.Count do Controls[i].Set_Visible(false); wordapplication1.commandbars.activemenubr.set_visible(false); <-- 上面这一句为我添加,但是运行出错
用那个控件?代码应该怎样写?
for i:=1 to MSWord.commandbars.count do
应该改为:
for i:=0 to MSWord.commandbars.count-1 do
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
I.Explain := '假如上述代码中出现“OA”等字样,删除它们';
I.Desire := '加不加分随你';
—————————————————————————————————
不是你说的这个原因,出错的那句根本就不认,不是循环下界的错
MSWord.CommandBars.Item[i].Visible:=false
还是不行,报错,不知什么愿因
你可以将:
for i:=1 to MSWord.commandbars.count do的循环值改小一点运行测试。
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
I.Explain := '假如上述代码中出现“OA”等字样,删除它们';
I.Desire := '加不加分随你';
—————————————————————————————————
程序可以将工具全部屏闭了,但是菜单还是不能屏闭,
同时程序运行时在这一句:MSWord.CommandBars.Item[i].Visible:=false
还是报错,我试过用SEVEL上面的控件,效果是一样的,
谢谢各位的支持,请再给点指点,
此贴再加50分,
if WordApplication1.CommandBars.ActiveMenuBar.Enabled then
with WordApplication1.CommandBars.ActiveMenuBar do
for i:=1 to Controls.Count do
Controls[i].Set_Visible(false);
你的这段代码可以将代码菜单全部屏闭掉,但是显示菜单的工具条不能屏闭,
我加了一条代码,如下所示,但是运行出错,
if WordApplication1.CommandBars.ActiveMenuBar.Enabled then
with WordApplication1.CommandBars.ActiveMenuBar do
for i:=1 to Controls.Count do Controls[i].Set_Visible(false);
wordapplication1.commandbars.activemenubr.set_visible(false); <--
上面这一句为我添加,但是运行出错