VBA更改Activex按钮的名称 [英] VBA to change the name of the Activex button

查看:101
本文介绍了VBA更改Activex按钮的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使有可能,我也不确定.我想在单击时更改按钮的名称.

I am not sure, even if this is possible. I would like to change the named of the button when clicked.

我有Active X按钮,单击该按钮将在工作表上启用单元格.按钮启用工作表"的名称.

I have Active X button that will enable cells on the sheet when clicked. Name of the button "Enable Sheet".

启用后,他应该会看到一个禁用工作表"按钮.请告知.

Once he enables, he should see a button "Disable Sheet". Please advise.

推荐答案

假定您的按钮以"CommandButton1"命名:

assuming your button is named after "CommandButton1":

Private Sub CommandButton1_Click()
    With Me.OLEObjects("CommandButton1").Object
        .Caption = IIf(.Caption = "Enable Sheet", "Disable Sheet", "Enable Sheet")
    End With
End Sub

在OP的评论后进行了编辑

edited after OP's comments

Private Sub CommandButton1_Click()    
    With Me.OLEObjects("CommandButton1").Object
        .Caption = IIf(.Caption = "Enable", "Disable", "Enable")
        Range("E13:E14").Locked = .Caption = "Enable"
    End With
End Sub

这篇关于VBA更改Activex按钮的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆