Microsoft KB Archive/827891

= Description of an undocumented expression for the OpenDataSource method SubType in Word 2007 and in Word 2003 =

Article ID: 827891

Article Last Modified on 1/25/2007

-

APPLIES TO


 * Microsoft Office Word 2007
 * Microsoft Office Word 2003

-





For a Microsoft Word 2002 version of this article, see 324378.



SUMMARY
Microsoft Office Word 2007 and Microsoft Office Word 2003 include an undocumented optional expression for the OpenDataSource method. This expression is named SubType.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Description of the OpenDataSource Method
This method attaches a data source to the specified document, and this document then becomes a main document. For more information about the OpenDataSource method, follow these steps.

Word 2007

 * 1) On the Developer tab, click Visual Basic.
 * 2) In the Visual Basic Editor, click Object Browser on the View menu.
 * 3) In the Search Text box, type OpenDataSource, and then click Search.

Word 2003

 * 1) On the Tools menu, point to Macro, and then click Visual Basic Editor.
 * 2) In the Visual Basic Editor, click Object Browser on the View menu.
 * 3) In the Search Text box, type OpenDataSource, and then click Search.

Description of the Optional SubType Expression
The SubType expression takes a parameter that is an optional Variant object, and this parameter determines the method that Word uses to open a data source. This parameter is one of the wdMergeSubType constraints. To make Word 2003 use the same connection methods as are used in earlier versions of Word -- specifically, Dynamic Data Exchange (DDE) for Microsoft Access and Microsoft Excel data sources -- use the following instance of the SubType expression:

SubType:=wdMergeSubTypeWord2000

The wdMergeSubType constraints include the following:
 * wdMergeSubTypeAccess
 * wdMergeSubTypeOAL
 * wdMergeSubTypeOLEDBText
 * wdMergeSubTypeOLEDBWord
 * wdMergeSubTypeOther
 * wdMergeSubTypeOutlook
 * wdMergeSubTypeWord
 * wdMergeSubTypeWord2000
 * wdMergeSubTypeWorks

For more information about the SubType expression, follow these steps:

Word 2007

 * 1) On the Developer tab, click Visual Basic.
 * 2) In the Visual Basic Editor, click Object Browser on the View menu.
 * 3) In the Search Text box, type SubType, and then click Search.

Word 2003

 * 1) On the Tools menu, point to Macro, and then click Visual Basic Editor.
 * 2) In the Visual Basic Editor, click Object Browser on the View menu.
 * 3) In the Search Text box, type SubType, and then click Search.

Sample Macro That Uses Microsoft Outlook for the Data Source
ActiveDocument.MailMerge.OpenDataSource&quot;&quot;,Connection :=&quot;Outlook&quot;, _ SQLstatement:=&quot;SELECT* FROM [Contacts]&quot;, SubType:=WdMergeSubTypeOutlook

Additional query words: inf VBA VBE WD2003 WD2007

Keywords: kbinfo KB827891

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.