Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word mail merge headaches
Message
De
15/07/2005 17:06:43
 
 
À
14/07/2005 15:09:20
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01032386
Message ID:
01033209
Vues:
22
>that would be great. I am not sure if I'll have the time to change the code right now but I would be interested in how you did that.

Here's what I did:
#DEFINE wdStory 6
#DEFINE wdpagebreak 7
#DEFINE wdLine 5

LOCAL loWord AS WORD.APPLICATION
TRY                      
	loWord = CREATEOBJECT("word.application")
	loDocOutPut = loWord.Documents.Add()
	m.lnRecCount = 0
	SCAN 
	   m.lnRecCount = m.lnRecCount + 1 
	   loDoc = loWord.Documents.Add(FULLPATH(m.TemplateFileName))
	   WITH loDoc

	      * we will assume the bookmarks in the document
	      * use the names of the fields
	      FOR EACH loBookmark IN .Bookmarks
	         loRange = loBookmark.Range()
	         loRange.Text = EVALUATE('TableAlias.' + loBookmark.name)
	      ENDFOR
	      .Select
	   ENDWITH 
	   WITH loWord
	      * copy the selected text and paste into output document
	      .Selection.Copy
	      loDocOutput.Select
	      .Selection.MoveDown(wdLine,1)
	      IF m.lnRecCount > 1
	         .Selection.InsertBreak(wdPageBreak)
	      ENDIF 
	      .Selection.PasteAndFormat(0)
	      
	      loDoc.close(.F.)
	   ENDWITH 
	   
	ENDSCAN 
	loDocOutput.SaveAs(m.lOutputFile)
	loWord.Selection.HomeKey(wdStory)
	loWord.visible = .T.

CATCH TO loError
	MESSAGEBOX( TRANSFORM(loError.Errorno) + ":" + loError.message)
	m.lPrintQuerySuccess = .F.
	loWord.Quit
	 
	RELEASE loWord
	  
ENDTRY 
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform