Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word automation and VFP.
Message
De
09/09/2004 17:02:18
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Word automation and VFP.
Divers
Thread ID:
00940838
Message ID:
00940838
Vues:
149
Hello,

I am trying to create a mail merge document and add one text and one field from a file called merge.dbf. I run the following code in VFP6 (moving to 8)
and get a dialog box asking to "Select Data Source". Here is the code:

#Define MYDBC "c:\proj2000\data\merge.dbf"

cSQLStatement1 = "SELECT * FROM Merge"
cSQLStatement2 = ""

oWordDocument=createobject("word.application") && Create word object
With oWordDocument
.Documents.Add && Use a predefined template if u wish
With .ActiveDocument.MailMerge
.OpenDataSource(,,,.T.,,,,,,,, ;
"DSN=Visual FoxPro Database;SourceDB="+MYDBC+;
";SourceType=DBF;Exclusive=No;",;
cSQLStatement1, cSQLStatement2) && Open data source - Link to source
.EditMainDocument && Activate the main document
.Application.Selection.TypeText("First Name :")
.Fields.Add(.Application.Selection.Range,'firstname')
.Application.Selection.TypeText(CHR(13)+"Blah blah ...."+Chr(13))
ENDWITH
.Visible = .t.
.Activate
EndWith

Any ideas what I am doing wrong? I need something VERY simple.

Thanks,

-Greg
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform