我要对所有excel设置菜单的某些功能不可显示
用createobject和new Excel.applition都是只对打开的某一excel操作,而不是对所有的。也就是说如果我通过程序设置excel打开菜单不显示,当我关闭程序后,启动excel,打开菜单应该不显示。代码如下:
Set ExcelApplication = CreateObject("Excel.Application")
For Each xlCmdBar In ExcelApplication.CommandBars
If xlCmdBar.NameLocal = "工作表菜单栏" Then
Set xlControl = xlCmdBar.Controls(1)
If Not IsNull(xlControl.CommandBar) Then
Set xlSubBar = xlControl.CommandBar
For Each xlSubCtrl In xlSubBar.Controls
If InStr(1, xlSubCtrl.Caption, "(&") <> 0 Then
If InStr(1, xlSubCtrl.Caption, "打开") = 0
xlSubCtrl.Visible = False
end if
End If
Next
End If
End If
Next通过开始菜单中的程序启动EXCEL打开菜单也能不显示。
请各位高手帮忙解决。
用createobject和new Excel.applition都是只对打开的某一excel操作,而不是对所有的。也就是说如果我通过程序设置excel打开菜单不显示,当我关闭程序后,启动excel,打开菜单应该不显示。代码如下:
Set ExcelApplication = CreateObject("Excel.Application")
For Each xlCmdBar In ExcelApplication.CommandBars
If xlCmdBar.NameLocal = "工作表菜单栏" Then
Set xlControl = xlCmdBar.Controls(1)
If Not IsNull(xlControl.CommandBar) Then
Set xlSubBar = xlControl.CommandBar
For Each xlSubCtrl In xlSubBar.Controls
If InStr(1, xlSubCtrl.Caption, "(&") <> 0 Then
If InStr(1, xlSubCtrl.Caption, "打开") = 0
xlSubCtrl.Visible = False
end if
End If
Next
End If
End If
Next通过开始菜单中的程序启动EXCEL打开菜单也能不显示。
请各位高手帮忙解决。
解决方案 »
- 字体在INI中更新问题
- 如果连接oracle数据源?
- 在字符串中搜索符合条件的
- 200分!!请问如何编程控制实现listview的水平滚动条的左右滚动?
- 为什么都一个窗体,me.Height和me.ScaleHeight的值差距非常大
- 我用ShowSave方式打开了commonDialog控件,问题是:我在程序中应怎样判断按的是对话框的确认健还是取消健
- Shell_NotifyIcon 问题
- 小问题快来拿分
- 请教高手:怎样才能有效地杀掉Office进程(word,excel,ppt)
- vb的datagrid控件的使用: 如何将文本文件先读入datagrid, 然后再更新到数据库中
- vb中delete键的值是多少?
- 请问我的这个串口通讯怎么会这问题啊!求教!
因为你对EXCEL.Application的操作,只是对EXCEL的一个实例的操作。可能需要改注册表,你上网查下资料吧。
-------------
直接把菜单项和工具按钮去掉,而不是让它不可见,参考:Set ExcelApplication = CreateObject("Excel.Application")
ExcelApplication.CommandBars("File").Controls(2).Delete
ExcelApplication.CommandBars("Standard").Controls(2).Delete