Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automation question (MS Word from VFP)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01144904
Message ID:
01144973
Vues:
14
I found a solution that will work... I used bookmarks to simplify things. First I created bookmarks in the document, then set the range for whichever bookmark I want and create the table there.

For Example:
oWord = CREATEOBJECT("Word.Application")
oDocument = oWord.Documents.OPEN("C:\Agrisoft\test.doc")

*-- Set the range for the first table to bookmark "BM1"
oRange = oWord.ActiveDocument.Bookmarks("BM1").Range

*-- Create the table at the bookmark selected and fill it with data
oTable = oDocument.TABLES.ADD(oRange,nRows,nCols)
SELECT FirstTable
nCounter = 1
SCAN
   oTable.Cell(1,1).RANGE.InsertAfter(FirstTable.SomeField1)
   oTable.Cell(1,1).RANGE.InsertAfter(FirstTable.SomeField2)
   nCounter = nCounter + 1
ENDSCAN

*-- Set the range for the second table to bookmark "BM2"
oRange = oWord.ActiveDocument.Bookmarks("BM2").Range

*-- Create the table at the bookmark selected and fill it with data
oTable = oDocument.TABLES.ADD(oRange,nRows,nCols)
SELECT SecondTable
nCounter = 1
SCAN
   oTable.Cell(1,1).RANGE.InsertAfter(SecondTable.SomeField1)
   oTable.Cell(1,1).RANGE.InsertAfter(SecondTable.SomeField2)
   nCounter = nCounter + 1
ENDSCAN
The end result is that no matter how many rows the first table has, I can get the second table built and populated directly below it (or wherever I want) by presetting some bookmarks in the document and using them to set oRange before creating the table.


>I think I have a way I can do what I need to do... which brings me to a second question. If I issue the following code:
>
>oWord = CREATEOBJECT("Word.Application")
>oDocument = oWord.Documents.OPEN("C:\test.doc")
>With oRange.Find
>   .Text="SomeText"
>   lFound = .Execute	
>EndWith
>
>
>If lFound = .T., how can I then set a new range (oRange) equal to the starting position of where the text was found?
>
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform