如何禁用工作表上的特定按钮?

问题描述 投票:0回答:1

我正在尝试禁用工作表上的按钮。我知道我可以使它不可见,但我宁愿将其显示在屏幕上但不能单击并显示为灰色,以便显然不能单击。

这是该按钮的脚本:

Sub LinkFile()
Call Module1.setup
Dim btn1 As Button
Dim t As Range

Set t = Range(Cells(3, "G"), Cells(4, "I"))

Set btn1 = ACImport.Buttons.Add(Left:=t.Left, Top:=t.Top, Width:=t.Width, Height:=t.Height)
btn1.Name = "Button1"
btn1.OnAction = "FileSearch"    ' MySub is executed when btn is clicked
btn1.Caption = "GO!"
End Sub

任何帮助将不胜感激。

谢谢

excel vba button hide
1个回答
0
投票

对于UserForms和ActiveX按钮,我相信这会起作用:btn1.Enabled = False

对于其他工作表按钮,请尝试:btn1.ControlFormat.Ebabled=False

ACImport.Shapes("Button1").ControlFormat.Enabled=False

© www.soinside.com 2019 - 2024. All rights reserved.