Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I have a word mail merge with only one record????
Message
De
09/12/1999 00:29:29
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00294139
Message ID:
00300823
Vues:
18
Hi John,

I have a working VFP 6 app that allows the user to print a letter using Word 97/Mail Merge from 1 record. When the user is in the appropriate client's form, she can click a button or menu pad and initiate the letter. I have taken the liberty of inclosing the code below. This may not be exactlly what your lookin for but maybe it will help. BTW I haven't worked out a way to print the envelope yet. If anyone has that done I'll appreciate their suggestsions. Also I couldn't find a way to print the current date on the letter from mail merge so I just created a field in the record and I store it there each time. If you know how to do that please advise although this works fine.

Of course the Word document was created using the Word Mail Merge facility pointing to my temp record "PrtDoc".

Regards,

Paige

Menu Selection passes 1 of 4 letter types - 3 for doctors, 1 for employees hired for perm or temp positions.

LPARAMETERS LetType
*
SET SAFETY OFF
IF LetType = 'A' OR LetType = 'B' OR LetType = 'C'
SELECT 0
USE Data\Doctors SHARED
*
IF LetType = 'C'
ENDIF
*
LOCATE FOR ID_Code = Hld_ID &&& Initialized in Form Init and Navigate
*
SELECT 0
USE C:\VDPI\PrtDoc EXCL
ZAP
APPEND BLANK
*
IF EMPTY(Doctors.Prefix)
REPLACE PrtDoc.Name WITH ALLTRIM(Doctors.First_Name)+' '+ALLTRIM(Doctors.Last_Name)
REPLACE PrtDoc.Company WITH Doctors.Company
REPLACE PrtDoc.Street WITH Doctors.Street
REPLACE PrtDoc.Apt_Box WITH Doctors.AptBox
REPLACE PrtDoc.City WITH Doctors.City
REPLACE PrtDoc.State WITH Doctors.State
REPLACE PrtDoc.Zip WITH Doctors.Zip
REPLACE PrtDoc.First_Name WITH ALLTRIM(Doctors.First_Name)
ELSE
REPLACE PrtDoc.Name WITH ALLTRIM(Doctors.Prefix)+' '+ALLTRIM(Doctors.First_Name)+' '+ALLTRIM(Doctors.Last_Name)
REPLACE PrtDoc.Prefix WITH ALLTRIM(Doctors.Prefix)
REPLACE PrtDoc.Last_Name WITH ALLTRIM(Doctors.Last_Name)
REPLACE PrtDoc.Company WITH Doctors.Company
REPLACE PrtDoc.Street WITH Doctors.Street
REPLACE PrtDoc.Apt_Box WITH Doctors.AptBox
REPLACE PrtDoc.City WITH Doctors.City
REPLACE PrtDoc.State WITH Doctors.State
REPLACE PrtDoc.Zip WITH Doctors.Zip
ENDIF
*
REPLACE CurrDate WITH MDY(Date())
*
SELECT Doctors
USE
SELECT PrtDoc
USE
*
DO CASE
CASE LetType = 'A'
cWordName = "C:\VDPI\DrPlcFee.doc"
CASE LetType = 'B'
cWordName = "C:\VDPI\DrAgree.doc"
CASE LetType = 'C'
cWordName = "C:\VDPI\DrPlace.doc"
ENDCASE*!* brow
*
ELSE
SELECT 0
USE Data\Employee SHARED
*
LOCATE FOR ID_Code = Hld_ID &&& Initialized in Form Init and Navigate
*
SELECT 0
USE C:\VDPI\PrtDoc EXCL
ZAP
APPEND BLANK
*
IF EMPTY(Employee.Prefix)
REPLACE PrtDoc.Name WITH ALLTRIM(Employee.First_Name)+' '+ALLTRIM(Employee.Last_Name)
REPLACE PrtDoc.Street WITH Employee.Street
REPLACE PrtDoc.Apt_Box WITH Employee.AptBox
REPLACE PrtDoc.City WITH Employee.City
REPLACE PrtDoc.State WITH Employee.State
REPLACE PrtDoc.Zip WITH Employee.Zip
REPLACE PrtDoc.First_Name WITH ALLTRIM(Employee.First_Name)
ELSE
REPLACE PrtDoc.Name WITH ALLTRIM(Employee.Prefix)+' '+ALLTRIM(Employee.First_Name)+' '+ALLTRIM(Employee.Last_Name)
REPLACE PrtDoc.Prefix WITH ALLTRIM(Employee.Prefix)
REPLACE PrtDoc.Last_Name WITH ALLTRIM(Employee.Last_Name)
REPLACE PrtDoc.Street WITH Employee.Street
REPLACE PrtDoc.Apt_Box WITH Employee.AptBox
REPLACE PrtDoc.City WITH Employee.City
REPLACE PrtDoc.State WITH Employee.State
REPLACE PrtDoc.Zip WITH Employee.Zip
ENDIF
*
REPLACE CurrDate WITH MDY(Date())
*
SELECT Employee
USE
SELECT PrtDoc
USE
*
cWordName = "C:\VDPI\EmpPlace.doc"
*
ENDIF
*
oWordDoc = CreateObject("Word.Application")
WITH oWordDoc
*!* .Visible = .T.
.Documents.Open(cWordName)
*!* .ActiveDocument.MailMerge.Destination = 1
.ActiveDocument.MailMerge.Execute
.ActiveDocument.PrintOut
.Documents.Close(0)
.Application.Quit
ENDWITH
RELEASE oWordDoc
*
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform