Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mail merge 2003
Message
De
22/06/2005 21:41:50
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01025176
Message ID:
01025679
Vues:
12
Borislav
This is the code I use and it works for all versions but Word 2003. Clients only has 1 word 2003 so perhaps there is something with the Word setup.
	oWorddoc=Createobject("word.application")&& Create word object
	oWorddoc.documents.open(cfileName)
	* Set text file as data source for mailmerge
	oWorddoc.DisplayAlerts = 0
        * datasource is tab delimited file created from a cursor.
	oWorddoc.Activedocument.MailMerge.OpenDataSource(m.lcSourceDoc)
	oWorddoc.Activedocument.MailMerge.Destination = 1 &&printer
	oWorddoc.Activedocument.MailMerge.Execute
	oWorddoc.documents.close(0)
	oWorddoc.application.quit
	release oWorddoc
The problem I am having is that Word open up a "save as" prompt in which the user needs to name the file which is then save as a document imaging file .mdi. Once they hit the save button the program open up a document imaging screen and you can print the merged letters from it

I would like to have the program do the merge and print the letters without any user intervention like it does in Word 97,2000,2002.

I read your code but since the above code works in all cases except 2003, I would like to stay with it if at all possible.

Any suggestion would be appreciated.

Gaylen





>>I have an application with a lot of letters being produced by Word using mail merge. The application works great for all version of Word 97-2002 without Word being visible or any action by the user.
>>
>>Tried to run the same routine on Word 2003 and it brings up a prompt dialog wanting to know the name of the merged file. Once they name the file it runs fine.
>>
>>Any way to circumvent the prompt and have it run without any user input.
>>
>>
>>Thanks
>>Gaylen
>
>I work with Word 2003 and have no problems at all. Here my last few rows of code where I actualy merge the document:
>
>
>oWord.ActiveDocument.MailMerge.EditMainDocument
>oWord.Visible = .f.
>WITH oWord.ActiveDocument.MailMerge
>     .Destination        = 0           && File
>     WITH .DataSource
>          .FirstRecord = 2
>          .LastRecord  = records_to_print
>     ENDWITH
>     .Execute(.t.)
>ENDWITH
>cWrdName = oWord.ActiveDocument.name
>
>*** Close ALL documents except the newly created file
>doc_to_close = 1
>DO WHILE oWord.Documents.Count > 1
>   nDoc = oWord.Documents(doc_to_close)
>   IF .NOT. cWrdName == nDoc.Name
>      nDoc.Close(0)
>   ELSE
>      doc_to_close = doc_to_close + 1
>   ENDIF
>ENDDO
>
>
>I forgot, try oWord.DisplayAlerts = 0
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform