Microsoft KB Archive/163729

= WD97: OLE Automation Fails When Using "Word.Basic" Object =

Article ID: 163729

Article Last Modified on 8/13/2007

-

APPLIES TO


 * Microsoft Word 97 Standard Edition

-



This article was previously published under Q163729





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 versions 6.x and 7.x.

The following file is available for download from the Microsoft Download Center:

Position.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.



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, 7.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 Visual Basic for Applications commands for Microsoft Word.

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:

105534 WD: OLE: Visual Basic 3.0 Does Not Support Named Arguments

112733 FILE: Help File for VB OLE Automation w/ Word for Windows

163618 WD97: 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, 7.x.

