Office VBA 参考Office VBA Reference

Office Visual Basic for Applications (VBA) 是事件驱动的编程语言,可以借助它扩展 Office 应用程序。Office Visual Basic for Applications (VBA) is an event-driven programming language that enables you to extend Office applications.

Office 中的 VBA 编程VBA Programming in Office

本参考适用于希望了解 VBA 和希望深入了解编程如何帮助他们自定义 Office 的有经验的 Office 用户。This article is for experienced Office users who want to learn about VBA and who want some insight into how programming can help them to customize Office.

应用程序的 Office 套件具有一套完整的功能。The Office suite of applications has a full set of features. 有多种不同的方法可以用来对文档、电子邮件、数据库、窗体、电子表格和演示文稿进行创作、格式设置和操纵。There are many different ways to author, format, and manipulate documents, email, databases, forms, spreadsheets, and presentations.

Office VBA 编程的杰出之处在于,你可以使用鼠标、键盘或对话框执行的每一个操作几乎也都可以使用 VBA 自动执行。The great power of VBA programming in Office is that nearly every operation that you can perform with a mouse, keyboard, or a dialog box can also be automated by using VBA. 此外,若某个操作可以使用 VBA 执行一次,则可以同样轻松地执行该操作一百次。Further, if it can be done once with VBA, it can be done just as easily a hundred times. 实际上,自动执行重复任务是 Office VBA 最常见的用途之一。In fact, the automation of repetitive tasks is one of the most common uses of VBA in Office.

除了可通过编写 VBA 脚本来加速执行日常任务外,还可以使用 VBA 为 Office 应用程序添加新功能,或以特定于业务需要的方式来提示文档用户并与之交互。Beyond the power of scripting VBA to accelerate every-day tasks, you can use VBA to add new functionality to Office 2010 applications or to prompt and interact with the user of your documents in ways that are specific to your business needs. For example, in Outlook 2010, you can use VBA to sort, export and modify contacts, e-mails, calendar items, or tasks in ways that are not available in the standard user interface. 例如,可以编写一些 VBA 代码,使其在用户首次尝试保存文档时显示一个弹出消息,提醒用户将文档保存到特定网络驱动器上。Beyond the power of scripting VBA to accelerate every-day tasks, you can use VBA to add new functionality to Office applications or to prompt and interact with the user of your documents in ways that are specific to your business needs. For example, you could write some VBA code that displays a pop up message that reminds users to save a document to a particular network drive the first time they try to save it.

另请参阅See also