Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Word automation and VFP.
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement