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

Last reviewed: February 11, 1998
Article ID: Q105534
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Access for Windows, version 2.0

SUMMARY

When you use a Microsoft Visual Basic 3.0 application, you cannot call a Visual Basic for Applications or WordBasic instruction using named arguments. Instead, you must identify these arguments by position using commas as placeholders.

NOTE: Visual Basic 4.0 supports named arguments.

Word 97 Visual Basic for Applications

The following example shows the Visual Basic for Applications syntax as it might appear in a Visual Basic for Applications macro in Word.

   Documents.Open FileName:="""table calculation.doc""", _
   ConfirmConversions:= False, ReadOnly:=False, AddToRecentFiles:=False, _
   PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
   WritePasswordDocument:="", WritePasswordTemplate:="", _
   Format:=wdOpenFormatAuto

Syntax for the above example

expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format)

To use this instruction in a Visual Basic 3.0 procedure, you would write:

   WordObj.Documents.Open "C:\Test.doc", False, False, False,,, False,,, 0

WordBasic

The following example shows the WordBasic syntax as it might appear in a Word macro. The instruction opens the document as a read-only file and adds the name to the MRU (Most Recently Used) list on the File menu.

   FileOpen .Name = "D:\Winword\Mydoc.doc", .ReadOnly = 1, AddtoMru = 1

To use this instruction in a Visual Basic procedure, you would write:

   WordObj.FileOpen "D:\Winword\Mydoc.doc", , 1, 1

WordObj is an object variable that refers to WordBasic (the complete Visual Basic procedure is included below). The extra comma after the file name is a placeholder for the ConfirmConversions parameter.

WordBasic parameter syntax:

   FileOpen .Name = text [, .ConfirmConversions = number]
    [, .ReadOnly = number] [, .AddToMru = number] [, .PasswordDoc = text]
    [, .PasswordDot = text] [, .Revert = number]
    [, .WritePasswordDoc = text] [, .WritePasswordDot = text]

The following Visual Basic procedure opens a Word Document as read-only with the file name appearing on the MRU (Most Recently Used) list on the File menu.

   Sub Command1_Click ()
      Dim WordObj As Object
      Set WordObj = CreateObject("Word.Basic")
      WordObj.FileOpen "D:\WINWORD\MYDOC.DOC", , 1, 1
   End Sub

MORE INFORMATION

If you want to leave out an argument, you must indicate the missing argument with a comma. Trailing commas at the end of an instruction can be omitted. In the example above, it is not necessary to add additional commas after the final argument.

WordBasic

Most WordBasic statements that correspond to dialog boxes and the positioning of the arguments is documented in the WordBasic Help topics. However, the WordBasic statements for some dialog box tabs include arguments that are irrelevant or that have no effect. Since these arguments are irrelevant, they are not documented in WordBasic Help. However, the Visual Basic 16-bit or 32-bit OLE Automation programmer needs to be aware of these arguments so that he or she can correctly specify arguments by position.

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).

Position.hlp is a Windows Help File version that is available from the Microsoft Software Library:

 ~ Position.exe (size: 47167 bytes) 

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


Additional query words: ole automation word basic object container
position
Keywords : kbwordvba winword word6 word7 word8 word95 word97 kbinterop kbole kbmacro
Version : 6.0 6.0a 6.0c 7.0 7.0a 97
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.