zoukankan      html  css  js  c++  java
  • 好久不写的VBA代码

    今天在解决一个问题的时候,使出了很久不用的VBA。这是在Excel里面的一个特殊功能。

    下面是代码的一部分,主要是增加和删除快捷菜单

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    '删除工具条
    On Error Resume Next
        Dim bar As CommandBar
        Set bar = Application.CommandBars("CELL")
        Dim ctrl As CommandBarControl
        bar.FindControl(Tag:=12000).Delete
    End Sub
    
    Private Sub Workbook_Open()
    '添加工具条
        Dim bar As CommandBar
        Set bar = Application.CommandBars("CELL")
        Dim ctrl As CommandBarControl
        
        
        '先判断是否有这个工具条
        Dim button  As CommandBarControl
        Set button = bar.Controls.Add(Type:=msoControlButton, temporary:=True)
        With button
            .Caption = "打印标识卡"
            .OnAction = "PrintAction"
            .Tag = 12000
        End With
    End Sub
    
    
    
    其他与业务有关的代码这里就不贴出来了
  • 相关阅读:
    Android通过包名启动应用程序
    android 通过反射方法获取状态栏高度
    Android在输入法界面监听按键(以返回键为例)
    Android主动弹出输入法
    Android使用内部类自定义控件
    Android中ListView列表Item的圆角效果实现
    Android中关于系统Dialog无法全屏的问题
    Dart学习记录(五)
    Dart学习记录(四)—— 库
    Dart学习记录(三)—— 泛型
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/1705602.html
Copyright © 2011-2022 走看看