|
楼主 |
发表于 2007-5-23 14:21
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
<div class="msgheader">QUOTE:</div><div class="msgborder"><b>以下是引用<i>yclotus</i>在2007-5-18 12:06:22的发言:</b><br/><p>每次右键时,调出的菜单太多,我把它改了改,仅显示自定义菜单,这样即整洁又好看,操作方便。。。 </p><p><img src="attachments/dvbbs/2007-5/20075181243468386.jpg" border="0" onclick="zoom(this)" onload="if(this.width>document.body.clientWidth*0.5) {this.resized=true;this.width=document.body.clientWidth*0.5;this.style.cursor='pointer';} else {this.onclick=null}" alt="" /><br/></p><p>在ThisWorkbook加入以下代码:</p><p>Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)<br/>With Application.CommandBars("cell") '尽量用wiht减少代码,增强可读性,已改<br/> .Reset<br/> For i = 1 To .Controls.Count<br/> If .Controls.Item(i).Visible = True Then .Controls.Item(i).Visible = False '隐藏可见菜单<br/> Next i<br/> With .Controls<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949) ''尽量用wiht减少代码,增强可读性,太多没改<br/> MCR.Caption = "合同管理系统 - 主界面"<br/> MCR.OnAction = "MenuMain"<br/> MCR.FaceId = 266<br/> MCR.BeginGroup = True<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "快速定位这个合同"<br/> MCR.OnAction = "MenuFindFast"<br/> MCR.BeginGroup = True<br/> MCR.FaceId = 371<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "详细显示这个合同的全部信息"<br/> MCR.OnAction = "MenuFindFastAll"<br/> MCR.FaceId = 274<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "在当前表格中查找合同号"<br/> MCR.OnAction = "MenuFindNumber"<br/> MCR.FaceId = 109<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "转换用印记录"<br/> MCR.OnAction = "MenuMainChange"<br/> MCR.FaceId = 640<br/> MCR.BeginGroup = True<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "自动缩放单元格"<br/> MCR.OnAction = "MenuCloseItem"<br/> MCR.FaceId = 1650<br/> MCR.BeginGroup = True<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "含税/不含税转换"<br/> MCR.OnAction = "MenuShuiShou"<br/> MCR.FaceId = 384<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "开启外部计算器"<br/> MCR.OnAction = "MenuOutCalcu"<br/> MCR.FaceId = 960<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "加/去 表格边框"<br/> MCR.OnAction = "MenuSetKuang"<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "加/去 表格突出背景"<br/> MCR.OnAction = "MenuSetBackColor"<br/> Set MCR = .Add(Type:=msoControlButton, ID:=2949)<br/> MCR.Caption = "显示图例"<br/> MCR.OnAction = "MenuShowColorSample"<br/> MCR.BeginGroup = True<br/> End With<br/>End With<br/>End Sub</p><p>不知道有没有人喜欢。。。</p></div><p></p>谢谢!这样一改菜单的确简单多了。 |
|