将 VBA 脚本转换为 .exe 文件

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

Converting the VBA script into .exe file

excelvbaexcel-vba

提问by TejaGogineni

Is there any way or a tool to convert VBA script into .exe file.

有什么方法或工具可以将 VBA 脚本转换为 .exe 文件。

Ex: I will just click on .exe file. so the macro should run automatically and it should work in the similar way we run manually from excel macros.

例如:我只需点击 .exe 文件。所以宏应该自动运行,它应该以类似于我们从 excel 宏手动运行的方式运行。

your inputs are really helpful.

你的意见真的很有帮助。

回答by vinkun

Just create a vbs file.

只需创建一个 vbs 文件。

It is almost the same language (VBS and VBA) so the 'translation' should be fairly easy.

它几乎是相同的语言(VBS 和 VBA),因此“翻译”应该相当容易。

You can even do easier like creating a vbs file that opens your workbook and runs the macro inside the workbook.

您甚至可以更轻松地创建一个 vbs 文件,以打开您的工作簿并在工作簿中运行宏。

The file would look like :

该文件将如下所示:

Dim XlApp
Dim wb
dim ws
Set XlApp = CreateObject("Excel.Application")
XlApp.Visible = True
Path = "myPath"
Set wb = XlApp.Workbooks.Open(path & "myworkbookname")
set ws = wb.Sheets("mySheetName")

wb.Application.run "module1.macro1"
wb.close