vba 基本语法和示例教程

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

Basic Syntax and Examples Tutorial

vbams-office

提问by user15453

At work I work closely with MS-Office. I have managed to generate some scripts that perform various tasks. While I can port functions to VBA with some difficulty, I do not fully understand the foundations of the VBA language.

在工作中,我与 MS-Office 密切合作。我设法生成了一些执行各种任务的脚本。虽然我可以很困难地将函数移植到 VBA,但我并不完全理解 VBA 语言的基础。

Items for which I seek basic syntax and examples include: 'hello world' program, loops, flow control, variable declaration, variable type conversions, Objects (if possible), file/user input/output, when 'with' block can be used, and so on.

我寻求基本语法和示例的项目包括:“hello world”程序、循环、流控制、变量声明、变量类型转换、对象(如果可能)、文件/用户输入/输出、何时可以使用“with”块, 等等。

Could someone provide me with a link to a VBA tutorial, perhaps with the details of the above items?

有人可以为我提供 VBA 教程的链接,也许包含上述项目的详细信息?

采纳答案by Mitch Wheat

The versions of VBA post Office 2000 are almost identical to VB6. This MSDN siteis a great place to start. The VB6 resource centermight also be of use.

VBA post Office 2000 的版本几乎与 VB6 相同。这个MSDN 站点是一个很好的起点。在VB6资源中心也可能是使用的。

回答by Mike Rodey

MSDN: Developing Office Applications Using VBA

MSDN:使用 VBA 开发办公应用程序

If you haven't taken a look at it already, you can learn a lot from Visual Basic help within Office. To access it open an Office program and press Alt+F11 to open the Visual Basic Editor. Then press F1 or navigate to Help -> Microsoft Visual Basic Help. Also, as Mitch mentioned, if you learn the basics of VB6 you can use the same syntax for VBA.

如果您还没有看过它,您可以从 Office 中的 Visual Basic 帮助中学到很多东西。要访问它,请打开一个 Office 程序,然后按 Alt+F11 打开 Visual Basic 编辑器。然后按 F1 或导航到“帮助”->“Microsoft Visual Basic 帮助”。此外,正如 Mitch 所提到的,如果您学习了 VB6 的基础知识,您可以对 VBA 使用相同的语法。

回答by Mitch Wheat

I think you will find this video tutorial pretty helpful:

我想你会发现这个视频教程很有帮助:

http://developresource.weebly.com/10/post/2011/11/vba.html

http://developresource.weebly.com/10/post/2011/11/vba.html

And there are some other great stuffs you can find there so have a try :)

你可以在那里找到其他一些很棒的东西,所以试试吧:)