zoukankan      html  css  js  c++  java
  • VBA命令按钮操作

    1、添加一个命令按钮
    Sub AddCommandBar()
    '命令
    Dim cbar  As CommandBarButton


    Set cbar = CommandBars("Standard").Controls("临时按钮")

    If Not cbar Is Nothing Then
        
    Exit Sub
    End If

        
    With CommandBars("Standard")
            .Protection 
    = msoBarNoProtection
            
            
    With .Controls.Add(msoControlButton, Before:=3)
                .DescriptionText 
    = "QuitWithoutSave"
                .Caption 
    = "临时按钮"
                .TooltipText 
    = "临时按钮"
                .Style 
    = msoButtonIconAndCaption
                .OnAction 
    = "QuitWithoutSave"
            
    End With
        
        
    End With
    End Sub

    Private Sub QuitWithoutSave()
        
    MsgBox "激活事件:临时按钮"
    End Sub
    2、删除命令按钮
    CommandBars("Standard").Controls("临时按钮").Delete

    3   修改word命令

    '修改word命令
    Sub FileSave()

    MsgBox ActiveDocument.Name

    If ActiveDocument.Saved = False Then
        ActiveDocument.Save
    End If

    End Sub


    Sub FileSaveAs()
        
    MsgBox "您不能另存文档"
    End Sub

     4、删除顶端菜单

     CommandBars.ActiveMenuBar.Controls("Custom").Delete
  • 相关阅读:
    性能优化方法(Z)
    .NetChajian
    ServiceStack.Redis订阅发布服务的调用(Z)
    C#操作XML总结
    WPF DataGrid 性能加载大数据
    Mongodb 基础(Z)
    WPF 主题切换(Z)
    .Net全景视图
    C#动态创建和动态使用程序集、类、方法、字段等
    P3370 【模板】字符串哈希
  • 原文地址:https://www.cnblogs.com/top5/p/1583817.html
Copyright © 2011-2022 走看看