Where to find VBA api documentation for MS Word
I u开发者_如何学JAVAsed 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.
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.
Any ideas on this?
Thanks, James
I believe that the docs you're looking for are on MSDN, try here.
Have you looked at the many links to resources at the Word Developer Center?
That will lead you to resources such as the Word Object Model Reference.
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
Here you'll find reference for older products http://msdn.microsoft.com/en-us/library/bb726434(v=office.12).aspx
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.
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 12.0 Object Library
- Microsoft Office 12.0 Object Library
- OLE Automation
- Visual Basic for Applications
These libraries contain functions and objects, some of which use similar names (e.g., MsgBox is a function; MessageBox either 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...
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:
(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:
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.
Update: It appears MS has updated/upgraded MS Word documentation. Try:
MS Object Model Reference
MS Word Client-Developer Home
Hope these help the next guy.
dj
精彩评论