Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP with MSWord
Message
De
22/03/1999 13:15:17
 
 
À
22/03/1999 13:11:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00200130
Message ID:
00200576
Vues:
8
Hello Rolf,

The following is an section of my code that prints letters and create an image file. I'm using VFP5.0 with latest patch and Word 7 with latest patch.

One thing I have not figured out how to do yet is to insert/replace. Hence I insert, print, close without save, then reopen.

If you have and questions I'll try to help. If you have any suggestions or answers I'll appreciate you getting back to me.

This is probably more than you wanted to know but:

*
COPY FILE C:\CVS\KeyLet01.doc TO C:\CVS\TempLet1.doc && KeyLet01 contains && appropriate book marks:
*
IF SUBSTR(lcAlphaCD,1,1) = '*'
NewCli = SUBSTR(lcClientCD,1,2)+'N'+'_' && Use Client and NO for Not in Compliance
ELSE
NewCli = SUBSTR(lcClientCD,1,2)+'N'+SUBSTR(lcAlphaCD,1,1) && Use Client and NO for Not in Compliance
ENDIF

NewMo=MONTH(DATE())
NewYr=LTRIM(STR(YEAR(DATE())))
IF NewMo -10 < 0
ImageFil='"C:\CVS\'+NewCli+'0'+LTRIM(STR(NewMo))+SUBSTR(NewYr,3,2)+'.DOC"'
ELSE
ImageFil='"C:\CVS\'+NewCli+LTRIM(STR(NewMo))+SUBSTR(NewYr,3,2)+'.DOC"'
ENDIF
&& above code is to assign a name to the image file.
*
COPY FILE C:\CVS\EMPTYDOC.DOC TO &IMAGEFIL
*
oWord = CreateObject("Word.Application")
WITH oWord
.Documents.open(&ImageFil)
*
GO TOP
SCAN WHILE NOT EOF()
IF Exp_26 < 3 && If LetNo > 2 - no more letters
.Documents.open('c:\CVS\TempLet1.doc')
.ActiveDocument.BookMarks("DateBK").Select
.Selection.Font.Name = ('Times Roman.ttf')
.Selection.Font.Size = 12
.Selection.TypeText(HldDATE2)
.ActiveDocument.BookMarks("AddrBk").Select
.Selection.Font.Name = ('Times Roman.ttf')
.Selection.Font.Size = 12
IF Ins_Last1>SPACE(30)
IF Ins_Midd1>SPACE(20)
IF SUBSTR(Ins_Midd1,2,19)>SPACE(20)
.Selection.TypeText(RTrim(Ins_First1)+' '+RTRIM(Ins_Midd1)+' '+RTrim(Ins_Last1)+' '+RTrim(Ins_Suffix))
ELSE
.Selection.TypeText(RTrim(Ins_First1)+' '+RTRIM(Ins_Midd1)+'. '+RTrim(Ins_Last1)+' '+RTrim(Ins_Suffix))
ENDIF
ELSE
.Selection.TypeText(RTrim(Ins_First1)+' '+RTrim(Ins_Last1)+' '+RTrim(Ins_Suffix))
ENDIF
ELSE
.Selection.TypeText(Ins_Party1+':')
ENDIF
.Selection.TypeParagraph
.Selection.TypeText(Ins_Addr1)
.Selection.TypeParagraph
IF Ins_Addr2 > SPACE(50)
.Selection.TypeText(Ins_Addr2)
.Selection.TypeParagraph
ENDIF
.Selection.TypeText(ALLTRIM(Ins_City)+', '+Ins_State+' '+SUBSTR(Ins_Zip,1,5))
.ActiveDocument.BookMarks("RegardBK").Select
.Selection.Font.Name = ('Times Roman.ttf')
.Selection.Font.Size = 12
.Selection.TypeText ('RE: ')
.Selection.TypeText(Ins_Propde)
.Selection.TypeParagraph
.Selection.TypeText(' ')
.Selection.TypeText(Ins_PropId)
.ActiveDocument.BookMarks("SalutaBK").Select
.Selection.Font.Name = ('Times Roman.ttf')
.Selection.Font.Size = 12
IF Ins_Last1 > SPACE(30)
IF Ins_Prefix = SPACE(15)
.Selection.TypeText('Dear '+RTrim(Ins_First1)+' '+RTrim(Ins_Last1)+' '+RTrim(Ins_Suffix)+':')
ELSE
.Selection.TypeText('Dear '+RTrim(Ins_Prefix)+'. '+RTrim(Ins_Last1)+' '+RTrim(Ins_Suffix)+':')
ENDIF
ELSE
.Selection.TypeText('Dear Sir or Madam:')
ENDIF
.Selection.TypeParagraph
.Selection.TypeParagraph
DO CASE && 0PL = No Prior Letter, 1PL = 1 Prior Letter,
&& 2PL = 2 Prior Letters
CASE Hist_code = 'C' AND Let_Cnt > 1 && Cancel/Not Current or No Info - 2PL
* .ActiveDocument.BookMarks("ExpireBK").Select
.Selection.TypeText('As you may recall, we have been retained by Key Bank and Trust to monitor')
.Selection.TypeText(' insurance compliance for their loan accounts. On ')
.Selection.TypeText(First_Date)
.Selection.TypeText(' and ')
.Selection.TypeText(Sec_Date)
.Selection.TypeText(' we sent letters notifying you of intent to cancel your insurance effective')
.Selection.TypeText(DTOC(Cancel_Dat))
.Selection.TypeText('. Your loan')
.Selection.TypeText(' agreement with Key Bank and Trust requires that you provide the')
.Selection.TypeText(' following insurance:')
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText('1. Physical damage coverage with deductibles not exceeding $500.00.')
.Selection.TypeParagraph
.Selection.TypeText('2. Key Bank and Trust as Loss Payee.')
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText('Please have your agent issue a certificate reflecting the items shown')
.Selection.TypeText(' above. The certificate should be forwarded to:')
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText(lcClientNa)
.Selection.TypeParagraph
.Selection.TypeText(lcClientA1)
.Selection.TypeParagraph
.Selection.TypeText(lcClientA3)
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText('If a certificate is not received within ten (10) days, your account will be')
.Selection.TypeText(' referred to Key Bank & Trust for their action.')
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText('Your cooperation in this matter will be appreciated. If you have any')
.Selection.TypeText(' questions, please contact me.')
.Selection.TypeParagraph
ENDCASE
*
.Application.PrintOut
.Selection.WholeStory
.Selection.Copy
.Documents(&ImageFil).Activate
.Selection.Paste
.Selection.InsertBreak(0)
.Documents('c:\CVS\TempLet1.doc').Activate
.ActiveDocument.Close(0)
ENDIF
*
IF TESTCNTR > 9
DO My2BUTRt WITH '5','20','20','65',"INPUT WINDOW","{ INPUT }",;
'Would you like to print', 'another test letter?',' ', ' ',' ',' ',' ',' '
IF m2BUTOpt > 1
return
ELSE
TESTCNTR = 0
ENDIF
ENDIF
*
ENDSCAN
* .ActiveDocument.Close(0)
.Documents(&ImageFil).Activate
.ActiveDocument.Save
.ActiveDocument.Close()
*
.Visible = .F.
ENDWITH
Release objword
*
ERASE C:\CVS\TempLet1.doc
*
WAIT WIND ' Reindexing Events History Table ' AT 15,45 NoWait NoClear
Select Events
REINDEX
*
WAIT WIND ' Mail Merge for Canceled & Expired Records Completed - Press any key to continue ' AT 15,25
*
set defa to c:\progra~1\devstu~1\vfp\cvsii
Return





Regards,

Paige
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform