WD98: OLE Automation Fails When Using "Word.Basic" Object

ID: Q183307

The information in this article applies to:

SYMPTOMS

When you use a programming language that calls a Visual Basic for Applications or WordBasic instruction using OLE Automation, and your calling application (for example, Microsoft Visual Basic 3.0,) cannot use named arguments, the OLE automation fails.

CAUSE

When you use a programming language that cannot call a Visual Basic for Applications or WordBasic instruction using named arguments you must identify these arguments by position using commas as placeholders.

RESOLUTION

To ensure the correct WordBasic command argument positioning when using OLE Automation to interact with Visual Basic for Applications, use the Position.hlp file for Word version 6.x.

The following file is available for download from the Microsoft Software Library:

 ~ Position.exe (size: 47167 bytes) 
                  This file contains a Help file (POSITION.HLP). This file
                  is for Visual Basic version 3.0 programmers who want to
                  use OLE Automation to access WordBasic in versions of
                  Microsoft Word.

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

MORE INFORMATION

Visual Basic for Applications includes a WordBasic Automation object (Word.Basic) that includes methods for all the WordBasic statements and functions available in Word versions 6.x.

WordBasic statements or functions in Microsoft Word can take named arguments. If your application does not support named arguments, and you send WordBasic commands through OLE Automation, your application must specify all the parameters to a WordBasic function in the proper order. The same call in WordBasic may only require some of the parameters using named arguments, and those parameters could be provided in any order.

For most WordBasic statements, the positioning of the arguments is documented in the WordBasic Help topics or printed reference entries for those statements. However, the arguments for some statements are not listed in proper order, or the arguments are irrelevant or have no effect. These arguments are not documented in WordBasic Help or in the printed reference.

For example, the InsertIndex statement corresponds to the Index tab in the Index and Tables dialog box. The InsertIndex statement takes a number of arguments that have to do with other tabs in the dialog box, such as the Table Of Contents tab. Because these arguments are irrelevant to inserting an index, they are ignored, and are therefore not documented in WordBasic Help or in the printed reference. But, as an OLE Automation programmer, you need to be aware of these arguments so you can correctly specify arguments by position.

NOTE: If your program was written to call WordBasic commands and you are anticipating interacting with the Microsoft Word Visual Basic for Applications language for all future development, it is recommended that you convert your code from WordBasic to the Microsoft Word Visual Basic for Applications commands.

For a listing of these statements and the correct order of the arguments, look to the Position.txt text file. This file is included on the disk included with the Word Developer's Kit (located in the Wrdbasic directory).

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

   ARTICLE-ID: Q161547
   TITLE     : WD: How to Use OLE Automation with Word 6.0/7.0

   ARTICLE-ID: Q105534
   TITLE     : WD: OLE: Visual Basic 3.0 Does Not Support Named Arguments

   ARTICLE-ID: Q112733
   TITLE     : FILE: Help File for VB OLE Automation w/ Word for Windows

   ARTICLE-ID: Q181394
   TITLE     : WD98: Writing Macro Code for VBA and WordBasic Branching

For information about WordBasic statements and functions, see the "Microsoft Word Developer's Kit" or WordBasic Help in Word versions 6.x.

REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications

Additional query words: wordcon vb vba vbe
Keywords          : kbfile kbdta kbdtacode OffVBA kbmacroexample macword98 
Version           : MACINTOSH:98
Platform          : MACINTOSH
Issue type        : kbprb

Last Reviewed: April 7, 1999