Description of an undocumented expression for the OpenDataSource method SubType in Word 2003 (827891)



The information in this article applies to:

  • Microsoft Office Word 2003

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

SUMMARY

Word 2003 includes 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:
  1. In Word, point to Macro on the Tools menu, 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:
  1. In Word, point to Macro on the Tools menu, 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"",Connection :="Outlook", _
    SQLstatement:="SELECT* FROM [Contacts]", SubType:=WdMergeSubTypeOutlook

REFERENCES

For more information about OpenDataSource, click Microsoft Visual Basic Help on the Help menu, type OpenDataSource Method in the Search for box in the Assistance pane, and then click Start searching to view the topic.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbinfo KB827891 kbAudDeveloper kbAudEndUser