Microsoft KB Archive/324378

= Description of the undocumented OpenDataSource method expression [SubType] in Word =

Article ID: 324378

Article Last Modified on 2/1/2007

-

APPLIES TO


 * Microsoft Office Word 2007
 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



This article was previously published under Q324378



SUMMARY
Microsoft Word includes a new, undocumented optional expression [SubType] for the OpenDataSource method.



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
The new optional expression attaches a data source to the specified document. This becomes a main document if it is not one already.

Sub OpenDataSource(Name As String, [Format], [ConfirmConversions], [ReadOnly], [LinkToSource], [AddToRecentFiles], [PasswordDocument], [PasswordTemplate], [Revert], [WritePasswordDocument], [WritePasswordTemplate], [Connection], [SQLStatement], [SQLStatement1], [OpenExclusive], [SubType])

To find this information about the OpenDataSource method, follow these steps:
 * 1) In Microsoft Office Word 2003 and in Microsoft Word 2002, point to Macro on the Tools menu, and then click Visual Basic Editor.

In Microsoft Office Word 2007, click the Developer tab, and then click Visual Basic in the Code group.
 * 1) In the Visual Basic Editor, click Object Browser on the View menu.
 * 2) In the Search Text box, type OpenDataSource, and then click Search.

Optional [SubType] Expression
The [SubType] parameter is an optional Variant that determines the method that Word uses to open a data source. It is one of the WdMergeSubType constraints. To have Word use the same connection methods as in earlier versions of Word, namely Dynamic Data Exchange (DDE) for Microsoft Access and Microsoft Excel data sources, use SubType:=wdMergeSubTypeWord2000.

WdMergeSubType constraints include:

wdMergeSubTypeAccess

wdMergeSubTypeOAL

wdMergeSubTypeOLEDBText

wdMergeSubTypeOLEDBWord

wdMergeSubTypeOther

wdMergeSubTypeOutlook

wdMergeSubTypeWord

wdMergeSubTypeWord2000

wdMergeSubTypeWorks

To find this information about the [SubType] expression, follow these steps:
 * 1) In Word 2003 and in Word 2002, point to Macro on the Tools menu, and then click Visual Basic Editor.

In Word 2007, click the Developer tab, and then click Visual Basic in the Code group.
 * 1) In the Visual Basic Editor, click Object Browser on the View menu.
 * 2) In the Search Text box, type SubType, and then click Search.

Sample Macro Code That Uses Microsoft Outlook As 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

Keywords: kbhowto KB324378

-

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

© Microsoft Corporation. All rights reserved.