在哪里可以找到 MS Word 的 VBA api 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7233140/
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
Where to find VBA api documentation for MS Word
提问by James Drinkard
I used to do VB and VBA coding, but it's been over 10 years since I've done any VB/VBA work. I used Visual Studio and it had built in code assist to handle the functions available for VBA work. Now I"m a java developer, so I don't have Visual Studio and I need to write some VBA scripts for working with some rtf documents using winword for 2010. I've created a basic script, which I'm running with Cscript.exe off the command line in XP, but it would really help to know what functions I have available to use with my word objects.
我曾经做过 VB 和 VBA 编码,但我已经有 10 多年没有做过任何 VB/VBA 工作了。我使用了 Visual Studio,它内置了代码辅助来处理可用于 VBA 工作的函数。现在我是 Java 开发人员,所以我没有 Visual Studio,我需要编写一些 VBA 脚本来使用 2010 年的 winword 处理一些 rtf 文档。我已经创建了一个基本脚本,我正在使用 Cscript 运行它。 exe 在 XP 中的命令行之外,但它确实有助于了解我可以与我的 word 对象一起使用的功能。
I tried going to the Microsoft website, but couldn't find what I was looking for. This seems like something that should be really easy to locate with Google, but hasn't been. I did find some code snippets for various things, but I wanted to know if there was something that shows the api functions for winword outside of Visual Studio? I've used POI, but I need to run the scripts directly through winword, so that isn't an option.
我尝试访问 Microsoft 网站,但找不到我要查找的内容。这似乎应该很容易通过 Google 找到,但事实并非如此。我确实找到了一些用于各种事物的代码片段,但我想知道是否有一些东西可以在 Visual Studio 之外显示 winword 的 api 函数?我用过 POI,但我需要直接通过 winword 运行脚本,所以这不是一个选项。
Any ideas on this?
对此有何想法?
Thanks, James
谢谢,詹姆斯
回答by Dana the Sane
回答by DOK
Have you looked at the many links to resources at the Word Developer Center?
您是否查看过Word 开发人员中心的许多资源链接?
That will lead you to resources such as the Word Object Model Reference.
这将引导您访问Word Object Model Reference等资源。
回答by bpgergo
I used to do VBA development like 10 years ago. Here's what I've found word 2010 reference http://msdn.microsoft.com/en-us/library/ff841702.aspx
10 年前,我曾经做过 VBA 开发。这是我找到的 Word 2010 参考 http://msdn.microsoft.com/en-us/library/ff841702.aspx
Here you'll find reference for older products http://msdn.microsoft.com/en-us/library/bb726434(v=office.12).aspx
在这里您可以找到旧产品的参考http://msdn.microsoft.com/en-us/library/bb726434(v=office.12).aspx
回答by CODE-REaD
This answer may seem fatuous to experienced VBA developers, but a few days ago I was in the same boat as the OP. The Java library has fairly straightforward documentation. Like the OP I stumbled around msdn.microsoft.com and found no "master" index of all MS Word VBA functions. I could always find information on a function or object if I knew what to ask for, but no comprehensive overview to browse. And to complicate things VBA <> Visual Basic <> VB.NET <> VBScript, so searches often turned up Microsoft's "answer" for something beside VBA.
对于有经验的 VBA 开发人员来说,这个答案似乎很愚蠢,但几天前我与 OP 处于同一条船上。Java 库有相当简单的文档。就像 OP 一样,我在 msdn.microsoft.com 上偶然发现了所有 MS Word VBA 函数的“主”索引。如果我知道要请求什么,我总是可以找到有关函数或对象的信息,但没有全面的概述可供浏览。并使事情复杂化VBA <> Visual Basic <> VB.NET <> VBScript,因此搜索通常会出现 Microsoft 对 VBA 之外的其他内容的“答案”。
Part of the problem is, MS Word VBA has access to a wide range of libraries, so no one library (or its API reference) covers them all. By default my Word 2007 installation links to the following:
部分问题是,MS Word VBA 可以访问范围广泛的库,因此没有一个库(或其 API 参考)涵盖所有这些库。默认情况下,我的 Word 2007 安装链接到以下内容:
- MS Word 12.0 Object Library
- Microsoft Office 12.0 Object Library
- OLE Automation
- Visual Basic for Applications
- MS Word 12.0 对象库
- Microsoft Office 12.0 对象库
- OLE自动化
- Visual Basic 应用程序
These libraries contain functionsand objects, some of which use similar names (e.g., MsgBoxis a function; MessageBoxeither a function OR an object). And that's just the beginning; there are numerous other libraries Word may link to, as revealed by Developer->Visual Basic->Tools->References...
这些库包含函数和对象,其中一些使用相似的名称(例如,MsgBox是一个函数;MessageBox是一个函数或一个对象)。而这只是开始;Word 可以链接到许多其他库,如Developer->Visual Basic->Tools->References...
The good news is, MS Word's Visual Basic editor contains comprehensive offline documentation for the default libraries listed above. It is accessible through Developer->Visual Basic->Help->F1
. This command should open a window with the following Table of Contents:
好消息是,MS Word 的 Visual Basic 编辑器包含上面列出的默认库的全面脱机文档。它可以通过Developer->Visual Basic->Help->F1
. 此命令应打开一个包含以下目录的窗口:
(if the TOC doesn't show, you may need to click on the pointed-to icon above). From here you may search, or drill down in the TOC to browse available objects and functions, as:
(如果 TOC 未显示,您可能需要单击上面指向的图标)。从这里您可以搜索或在 TOC 中向下钻取以浏览可用的对象和功能,如下所示:
As I said, this answer will seem obvious to the experienced user. But I leave it nonetheless for those beginning their travels in the labyrinth of Visual Basic for Applications.
正如我所说,这个答案对于有经验的用户来说似乎是显而易见的。但我还是将它留给那些开始在Visual Basic for Applications迷宫中旅行的人。
回答by dj Quecke
Update: It appears MS has updated/upgraded MS Word documentation. Try:
更新:看来 MS 已经更新/升级了 MS Word 文档。尝试:
Hope these help the next guy.
希望这些能帮助下一个家伙。
dj
DJ