Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I need Word 2007 openDataSource help
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01332346
Message ID:
01332815
Vues:
14
Here one solution posted by Cetin Basoz:
Wait Window Nowait "Creating Word Document.Please wait..."
* Word constants header file - you can create this file using object browser
* Drag&drop constants node from MS Word COM on to an open code window
* and save as wdconst.h
#include "wdconst.h"
#Define NL Chr(13)+Chr(10)
m.lcConnection = "Provider=VFPOLEDB;Data Source="+_samples+'data\testdata.dbc'
TEXT TO m.lcUDL TEXTMERGE noshow
[oledb]
<<m.lcConnection>>
ENDTEXT

m.lcSource = Forcepath(Sys(2015)+'.udl',Sys(2023))
Strtofile(m.lcUDL,m.lcSource)
lcSQLStatement = "select first_name,last_name,title,hire_date,notes from employee"
*** set the LOCALEID to English
nlLocaleId=Sys(3004)  && Save local id
=Sys(3006,1033)    && We will be sending instructions in English
*** set the LOCALEID to English

oWordDocument=Createobject("word.application") && Create word object
With oWordDocument
  .documents.Add
  With .ActiveDocument.Mailmerge
    .OpenDataSource(m.lcSource, wdOpenFormatAuto,,,.T.,,,,,,,m.lcConnection, m.lcSQLStatement)
    .EditMainDocument	&& Activate the main document
.....
  ENDWITH
.....
ENDWITH
>My issue is (I think???), I have used 2 datasources in the past (2000, 2003) to produce this memo. I used a headersource and datasource for the top of the memo and inserted a table query for the bottom of the memo. Word2007 broke that. It appears I have to use one odc file to attach one datasource. The code below was my attempt to open the datasource directly, using an odc file...in my dreams I guess!
>
>Is there a way to use 2 different datasources with 1 doc in word 2007?
>
>>>This is the code I use to TRY to start a mailmerge. I do not want to use wizard to attach data, rather merge data on the fly. I looked at Marcia Atkins white paper but it is a little confusing. Here is the code. Her example shows "Entire Spreadsheet" for the connection parameter. Is that right? I am also getting an error "type mismatch". What am I missing?
>>>
>>>oWord=GETOBJECT('','word.application')
>>>oDoc=oWord.Documents.Open("filePath+docName")
>>>oDoc.MailMerge.OpenDataSource("dbfPath+dbfName", 0, 0, 1, 0, "", "", 0, "", "", "Entire Spreadsheet", "", "" )
>>>
>>
>>I saw you use variables, but you don't need to round them in quotes, so:
>>
>>oWord = GETOBJECT('','word.application')
>>oDoc  = oWord.Documents.Open(filePath+docName)
>>oDoc.MailMerge.OpenDataSource(dbfPath+dbfName, 0, 0, 1, 0, "", "", 0, "", "", "Entire Spreadsheet", "", "" )
>>
>>
>>DBF?
>>I just saw that you use DBF for DataSource, is that right?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform