vba excel宏可以在浏览器上运行吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21324138/
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-12 01:31:15  来源:igfitidea点击:

Can excel macro run on browser?

excelvbaexcel-vba

提问by clarencevictoria

Is it possible to run a macro on web browser? I can open an excel in a browser but i am not sure if macro can run with it. And also, how am I going to enable it automatically within a browser?

是否可以在 Web 浏览器上运行宏?我可以在浏览器中打开一个 excel,但我不确定宏是否可以用它运行。而且,我将如何在浏览器中自动启用它?

回答by Kelvin Dealca

If I am correct in assuming that you're asking if a vba macro can be run automatically after opening it from a link on a webpage rendered by a browser, the best way to do that is to set code to run automatically whenever the workbook linked in the webpage is opened.

如果我假设您询问是否可以在从浏览器呈现的网页上的链接打开 vba 宏后自动运行它是正确的,那么最好的方法是将代码设置为在工作簿链接时自动运行在网页中打开。

To have a macro run when a workbook is opened double click the "ThisWorkbook" object in the vba project explorer of the workbook that has your code and add these lines of code

要在打开工作簿时运行宏,请双击包含您的代码的工作簿的 vba 项目资源管理器中的“ThisWorkbook”对象并添加这些代码行

Private Sub Workbook_Open()
Call Module1.hello 'Change this line to start your code
End Sub

This automatically executes the sub "hello" in Module1 of the workbook.

这会自动执行工作簿 Module1 中的子“hello”。

Note that the user has to have Macros Enabled in their Trust Center Settings for anything to run.

请注意,用户必须在其信任中心设置中启用宏才能运行任何内容。

Also note that depending on their browser and where the actual link points to the workbook file might have to be downloaded first and then opened from the download location for the macro to run.

另请注意,根据他们的浏览器以及指向工作簿文件的实际链接的位置,可能必须首先下载,然后从下载位置打开宏才能运行。