Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need help with word automation syntax
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00510195
Message ID:
00510199
Vues:
20
Hi David,

Comments in-line with your question.


>I am a newbie to doing word automation. I am having trouble with the syntax for executing some of the methods. I have seen the documentation on MSDN (as discussed in other threads)
>
>This is what I want to accomplish:
>
>
>1) I have a 'base' word document. It has mostly fixed text, but some variable text. Most of the variable text is in tables. Some is embedded within a paragraph.
>
>2) I want to copy the base document to another temp document and then open the temp document with word automation.
>
>3) I want to write changes to the variable text and save the temp document.
>
>4) I want to print the temp document via word automation.
>
>I am good with steps 1,2 and 4.
>
>How can I access and write to individual cells in the table. How can I change other variable text that is not in a table.
>
>The online documentation on MSDN gives an example of making a document the active document:
>
>Documents("MyDocument.doc").Activate
>What is the VFP equivalent for this?
>
>I already have:
>
>oWord=CREATEobject("Word.Application")
>lcfilename='execsum\'+'execsummain3.doc'
>oWord.Visible= .t.
>oDoc=oWord.Documents.Open(lcfilename)
>** the above works
>** next i want to activate the document, and write changes to a table cell
>
>** the code below doesnt' work
>odoc.activate("execsummain3.doc") && error ole error code 80020011 - does not *support a collection

You already have a reference to a document in your oDoc variable. You should just be able to use oDoc.Activate.

>
>wait wind odoc.activedoc.tables(1).cell('Row:=1', 'Column:=1')

Again, you don't need oDoc.ActiveDoc - ActiveDoc is an application property that returns a reference to a document. You've already got a reference to the appropriate document.

Next, you can't use named arguments in VFP. You need to do away with the Row:= and the Column:= parts - you should use odoc.tables(1).cell(1, 1).


>** get activedoc is not an object (or similar)
>
>**what should the syntax be for activating the document, writing changes to the
>** table
>***********************
>
>**this works
>odoc.close()
> oword.quit(0)
>
>TIA

Cheers,

Andrew


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform