是否可以将 VBA 表单作为 .exe 文件运行

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

Is it possible to run a VBA form as a .exe file

formsvba

提问by tksy

Is it possible to save a form in VBA as .exe file and then run it.

是否可以将 VBA 中的表单另存为 .exe 文件然后运行它。

回答by Patrick Cuff

No, not natively.

不,不是原生的。

There are some ways to emulate an EXE:

有一些方法可以模拟 EXE:

  • Excel: 3rd party tool that claims to be able to compile an workbook to an EXE: DoneEx XCell Compiler. You can also create an automatic marco, Auto_Open, to run when the workbook is opened.
  • Access: Microsoft used to have a way of delivering an Access database as an executable (the name of the tool escapes me) so you could deploy your database to desktops that didn't have Access installed, but I don't think they offer this anymore. You could convert you MDB to an MDE and set the startup properties to hide the database window and menus and such to emulate an EXE, but your users will need to have Access installed.
  • Word: You can pass the /mswitch to Word on startup with the name of a macro to run.
  • Excel:声称能够将工作簿编译为 EXE 的第 3 方工具:DoneEx XCell Compiler。您还可以创建一个自动宏 Auto_Open,以在工作簿打开时运行。
  • Access:Microsoft 曾经有一种方法可以将 Access 数据库作为可执行文件提供(该工具的名称使我无法理解),因此您可以将数据库部署到未安装 Access 的桌面上,但我认为他们不提供此功能了。您可以将 MDB 转换为 MDE 并设置启动属性以隐藏数据库窗口和菜单等以模拟 EXE,但您的用户需要安装 Access。
  • Word:您可以/m在启动时使用要运行的宏的名称将开关传递给 Word。

回答by Fredou

I think there is at least 2 way

我认为至少有两种方式

move the code into visual basic 6 and compile it or use visual studio tool for officeand see what you can do.

将代码移动到visual basic 6并编译它或使用visual studio tool for office,看看你能做什么。

if these 2 solutions is a no no for you, then you are out of luck

如果这 2 个解决方案对您来说不是,那么您就不走运了

回答by Wolf5

No. VBA is an addon to applications to support "scripting" in the form of VB. So unless your application supports a way to save the internal script as en external EXE, you are out of luck.

不。VBA 是应用程序的一个插件,以支持 VB 形式的“脚本”。因此,除非您的应用程序支持将内部脚本另存为外部 EXE 的方法,否则您就不走运了。

回答by Ross

I think DoneEx still needs Excel installed, it just bootstraps something to the xls file, or bootstraps that to something and wraps it up as an exe???/..

我认为 DoneEx 仍然需要安装 Excel,它只是将某些内容引导到 xls 文件,或者将其引导到某些内容并将其包装为 exe???/..

as I think this does. http://cpap.com.br/orlando/XLtoExeMore.asp

正如我认为的那样。 http://cpap.com.br/orlando/XLtoExeMore.asp

But at least the second one if free!

但如果免费,至少第二个!

I have not tested on PC's with out office.

我没有在没有办公室的 PC 上测试过。

what is it you are trying to accomplish there may be a work around another way?

你想完成什么可能有另一种解决方法?

thanks Ross

谢谢罗斯