Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word automation and VFP.
Message
From
09/09/2004 17:02:18
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Word automation and VFP.
Miscellaneous
Thread ID:
00940838
Message ID:
00940838
Views:
151
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
Next
Reply
Map
View

Click here to load this message in the networking platform