怎样使用VBA添加“返回首页”功能于右键中?
1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行
Private Sub Workbook_BeforeClose(Cancel As Boolean) '关闭工作表时恢复菜单
Application.CommandBars(36).Reset
Application.CommandBars(39).Reset
End Sub
Private Sub Workbook_Open()
With Application.CommandBars(36).Controls.Add(Type:=msoControlButton,
before:=3, Temporary:=True)
.Caption="返回首页(&H)..." '普通视图下添加菜单
.OnAction="返回"
.FaceId=484
End With
With Application.CommandBars(39).Controls.Add(Type:=msoControlButton,
before:=3, Temporary:=True)
.Caption="返回首页(&H)..." '分页预览视图下添加菜单
.OnAction="返回"
.FaceId=484
End With
End Sub
5、在Sheet1工作表中单击右键,可以发现已按照需求增加了“返回首页”菜单,单击该菜单,则激活工作簿中排于最前面的工作表
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:83
阅读量:110
阅读量:138
阅读量:173
阅读量:79