oWord = getobject("", "Word.Application") oWord.visible = .t. lcFileName = alltrim(v_letters.le_path) && document to open lnConfirmConversions = 0 lnReadOnly = 0 lnAddToRecentFiles = 0 lcPasswordDocument = "" lcPasswordTemplate = "" lnRevert = 0 lcWritePasswordDocument = "" lcWritePasswordTemplate = "" oWord.Documents.Open(; lcFileName,; lnConfirmConversions,; lnReadOnly,; lnAddToRecentFiles,; lcPasswordDocument,; lcPasswordTemplate,; lnRevert,; lcWritePasswordDocument,; lcWritePasswordTemplate )This opens up the document and I am able to see the layout of the address fields etc...
lcDataFile = oApp.RootFolder + "\data\db.dbc" && full path to the database and the database name lcName = oApp.RootFolder + "\data\db.dbc" lnConfirmConversions = 0 lnwdOpenFormatAuto = 0 lnReadOnly = 0 lnLinkToSource = 1 lnAddToRecentFiles = 0 lcPasswordDocument = "" lcPasswordTemplate = "" lnRevert = 0 lcWritePasswordDocument = "" lcWritePasswordTemplate = "" lcConnection = "DSN=Visual FoxPro Database;UID=;PWD=;SourceDB=" + lcDataFile + ";SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=MACHINE;Null=Yes;Deleted=Yes;" lcSQLStatement = "SELECT * FROM db!contacts WHERE Contacts.co_primary = ?vPrimary" oWord.ActiveDocument.MailMerge.OpenDataSource(; lcName,; lnwdOpenFormatAuto,; lnConfirmConversions,; lnReadOnly,; lnLinkToSource,; lnAddToRecentFiles,; lcPasswordDocument,; lcPasswordTemplate,; lnRevert,; lcWritePasswordDocument,; lcWritePasswordTemplate,; lcConnection,; lcSQLStatement,; lcSQLStatement1 )But it errors at this point with "OLE lDispatch exception code 0 from Microsoft Word: Word was unable to open the data source...