Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word automation question
Message
De
29/05/2003 16:35:20
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Word automation question
Divers
Thread ID:
00794194
Message ID:
00794194
Vues:
66
Hi,

I am trying to automate a mailmerge using VFP6 and Word2000.

Things (almost) work as planned. I am stuck with a problem of controlling WHERE insertions happen in a table. I have looked for some documentation for Tables[].Rows[] but couldn't find anything I could use.

The problem is that I can get one of 2 results:
1- the 1st row is actually inserted into the column titles making the whole merge unusable
2- if I force an Add() at the beginning, all rows are inserted properly except I am left with the 1st row BLANK. How can I specifically delete a row ?

Can anyone point me to a useful description of the few calls I need (sourcedoc, tables, rows, etc...) ?

Thanks

Henry

The code follows:
================================================
* Create an instance of Word.
This.oWord = CreateObject("Word.Application")
* Word 2000 detaches connection if datasource not found
If File(goapp.cMMHeader+[.doc])
Erase (goapp.cMMHeader+[.doc])
Endif
* Create a document object
This.oDocument = This.oWord.Documents.Open(goapp.cMMDocument)
Local loSourceDoc, loRow, loTable
Select (goapp.cMMCursor)
With This.oDocument.MailMerge
* Attach the data to the document
.CreateDataSource(goapp.cMMHeader, , , goapp.cMMFieldList)
.EditDataSource
loSourceDoc = This.oWord.ActiveDocument
loTable = loSourceDoc.Tables[1]
loRow = loTable.Rows[1]
* loRow = loTable.Rows.Add()
* Now open the data source and put the data into the document
Scan
*For clarity, assume all fields are of type 'C'
For I = 1 To Occurs([,],goapp.cMMFieldList)+1
loRow.Cells[ I ].Range.InsertAfter(Trim( Eval(Fields( I ))))
EndFor
loRow = loTable.Rows.Add()
EndScan
loRow.Delete()
loSourceDoc.Save()
EndWith
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform