WD2002: Undocumented OpenDataSource Method Expression [SubType] (324378)



The information in this article applies to:

  • Microsoft Word 2002

This article was previously published under Q324378

SUMMARY

Microsoft Word 2002 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, which 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 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.

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, 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 Code That Uses Microsoft Outlook As the Data Source

ActiveDocument.MailMerge.OpenDataSource "",Connection :="Outlook",
SQLstatement:="SELECT* FROM [Contacts]", SubType:=WdMergeSubTypeOutlook
				

REFERENCES

For more information about OpenDataSource, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type OpenDataSource Method in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto KB324378