vba VBA单击Excel工作表中的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12616165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 14:05:08  来源:igfitidea点击:

VBA to click a button in a excel sheet

excelvba

提问by user1702478

i need to click a button(FormControl) on an excel sheet and run the macro assigned to it, through VBA code.

我需要单击 Excel 工作表上的按钮(FormControl)并通过 VBA 代码运行分配给它的宏。

I tried what was suggested here https://stackoverflow.com/questions/130166/clicking-command-button-from-other-workbook but it didn't work for me.

我尝试了这里的建议 https://stackoverflow.com/questions/130166/clicking-command-button-from-other-workbook但它对我不起作用。

Is there any other way to do this ??

有没有其他方法可以做到这一点?

回答by Tristan Reischl

Fairly easy method for doing this, even if it's not really documented.

执行此操作的相当简单的方法,即使它没有真正记录在案。

CommandButton1.Value = True

回答by GSerg

Did you actually try? Because you want exaclty what is suggested there.

你真的尝试了吗?因为您想要精确地建议那里的内容

Application.Run Activesheet.Shapes(1).OnAction

回答by Damian

If in a worksheet. I used this in the past and it worked!

如果在工作表中。我过去用过这个,它奏效了!

Sheet1.CommandButton1_Click

else

别的

Sheets("Sheet Name").CommandButton1_Click