Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending Mail Merge Documents via Outlook
Message
From
15/02/2002 09:45:18
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00619001
Message ID:
00620635
Views:
23
>oWord=CreateObject("Word.Application")
>oWordobj="oWord.WordBasic"
>WITH &oWordObj
> .FileNewDefault()

Let's start by getting rid of the WordBasic stuff. There's no reason to use it and it just confuses things (at least, me <g>). So change the above to:

oWord=CreateObject("Word.Application")
oDoc = oWord.Documents.Add()

> .MailMergeOpenDataSource(lcData,0,0,1,0,"","",0,"","",lcDSN,lcSQL,"")
> .MailMerge(1,0,0,"","",0,1)
> .FileSaveAS("abc.doc")

For this part, you want to work with the MailMerge object of the document:

WITH oDoc.MailMerge
.OpenDataSource()
.Execute()
ENDWITH
oWord.ActiveDocument.SaveAS("abc.doc")


>Thru tracing I found that the value of .MailMergeMainDocumentType defaulted to -1 but then changed after the OpenDataSource statement to 0. Additionally, when I tried to use the code .mailmergetodoc, I got an error that the file has no merge fields in it! But when I try to fax or email to a client they can't open the file because it seems to be connected with the data source! Help. (and Thanks.)

Sounds like there's a problem with the data source and you're not actually creating a result document. If that's the case, then what you're saving is probably the main document.

Make the switch to the newer syntax and then see what happens. In particular, see whether the OpenDataSource call works.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform