从哪里开始在 Word 2007 中进行 VBA 和宏编程?
我刚刚知道Word/Excel/PowerPoint 中的宏是可以编程的。这太棒了,因为我有一个包含 70 个样式表的 Word 文档。
我是一名程序员,但我不懂 VB、VBA 或 VB .NET。我对这三个感到困惑。我熟悉使用 C# 进行 .NET 编程。现在我想编写新的宏。我应该从哪里开始?什么是 VB、VBA、VB.NET?我应该学习哪一种?请推荐一些材料。
如果我学习 Word 2007,将会对其他 Office 应用程序生活、Excel 和 Excel 有所帮助。微软幻灯片软件?
I just came to know that macros in Word/Excel/PowerPoint can be programmed. That is awesome because I've a Word document with 70 tables for styling.
I'm a programmer but I don't know VB, VBA or VB .NET. I'm confused with these three. I'm familiar with .NET programming using C#. Now I want to write new macros. Where should I get started? What are VB, VBA, VB.NET and which one should I learn? Please suggest some material.
If I learn for Word 2007 will that help with other Office applications life Excel & PowerPoint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是不同 Visual Basic 的简要说明:
如果您预计在 VBA 中进行大量开发,我强烈推荐 < em>VBA 开发人员手册,第二版,作者:Getz 和 Gilbert。
当您使用 Excel、Access 等时,学习 Word 的 VBA 语法肯定会对您有所帮助。但是,每个应用程序都有自己的 API,这些 API 提供了一组特定于其领域的对象和方法。例如,我对Excel和Access中的VBA编程非常熟悉,但我从未在Word中做过宏编程。尽管代码语法是相同的,但我必须学习 Word 的 API 才能针对它进行编程。
某些 Office 应用程序(例如 Excel)的好处是您可以录制宏,查看它生成的代码,然后调整该代码以执行您想要的操作。这很大程度上就是我开始编程的方式。
Here's a brief explanation of the different Visual Basics:
If you anticipate doing a lot of development in VBA, I would highly recommend the VBA Developer's Handbook, Second Edition, by Getz and Gilbert.
Learning the VBA syntax for Word will certainly help you when you go to use Excel, Access, etc. However, each application has its own API that provides a set of objects and methods unique to its domain. For example, I'm very familiar with programming in VBA in Excel and Access, but I have never done macro programming in Word. Although the code syntax would be the same, I'd have to learn Word's API to be able to program against it.
The nice thing about some of the Office applications (Excel, for example) is that you can record a macro, see what code it generates, and then tweak that code to do what you want. That's largely how I got started in programming.
这里有一些很好的答案 - 我想提供另一组建议:
首先,如果您的环境支持,您可以使用 Visual Studio 2005/8/10 和您的 C# 技能通过“Visual Studio Tools”针对 Office 进行编程为办公室”。有关更多详细信息,请参阅此线程。
如果您想深入研究 VBA(我个人很喜欢 VBA,因为与 VS 相比,开发速度非常快),请从这篇文章开始VBA、Visual Basic .NET 和 C# 的十种代码转换,它将向您展示所有三种语言的示例。接下来,观看此网络广播:使用 Visual Basic应用程序 (VBA) 每天都比您想象的更容易。
第三- MSDN,阅读以下内容:在 Word 2010 中开始使用 VBA 。其中 99% 适用于 Word 2007。还有许多其他文章链接到此文章,或者您可以随时转到 Office VBA开发者中心作为单个跳转页面。
然后可能是时候开始直接编程了。了解其工作原理、了解 Word 的对象模型等。可以随时在 word-vba 标签下浏览 SO,看看其他人正在尝试什么要做的事和答案。
There are some good answers here - I'd like to offer one more set of suggestions:
First, if supported in your environment, you can use Visual Studio 2005/8/10 and your C# skills to program against Office with "Visual Studio Tools for Office". See this thread for more details.
If you want to delve into VBA instead (which I personally love because development is so fast compared to VS), start with this article Ten Code Conversions for VBA, Visual Basic .NET, and C# which will show you samples from all three languages. Next, watch this webcast: Using Visual Basic for Applications (VBA) Every Day Is Easier Than You Think.
Thirdly- MSDN, read through this: Getting Started with VBA in Word 2010. 99% of it applies to Word 2007. There are many other articles linked from this one or you can always go to the main page of Office VBA Developer Center as a single jump page.
Then it's probably time to get started to directly program. See how things work, learn Word's Object Model, etc. You can always browse SO under the word-vba tag to see what other people are trying to do and the answers.
您始终拥有 MSDN。
如果您转到 Microsoft Word >开发商> Visual Basic 并在左侧菜单中打开 ThisDocument,您将拥有编辑器。如果按F2,您将获得可在 Microsoft Word(对象浏览器)中使用的库。最简单的程序如下:
当您标记了子项后,按F5(运行)。
在对象浏览器中,您将看到三个不同的对象、属性、函数和事件。当您看到引起您兴趣的内容时,请转到 单词 vba 的参考并找到它。
[如果链接发生变化,您可以在 MSDN Library > 下的树中找到它写字楼发展> 2007微软Office系统》 Word 2007 > Word 2007 开发人员参考 > Word 对象模型参考]
我认为最简单的事情就是定义一个需要解决的问题并尝试对其进行编程,类似于学习任何其他语言。不要让问题变得简单,但也不要让问题变得困难而放弃。
You always have MSDN.
If you go to Microsoft Word > Developer > Visual Basic and open up ThisDocument in the left menu, you will have the editor. If you press F2 you will get the libraries that can be used in Microsoft Word (the Object Browser). The easiest program would be the following:
When you have the sub marked, press F5 (to run).
In the Object Browser you will have three different objects, properties, functions and events. When you see something that strikes your interest, go to the reference for word vba and locate it.
[If the link changes, you can find it in the tree under MSDN Library > Office Development > 2007 Microsoft Office System > Word 2007 > Word 2007 Developer Reference > Word Object Model Reference]
I think the easiest thing to do is to define a problem you need fixed and try to program it, similar to learning any other language. Don't make the problem to easy, but not to hard that you give up.