Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MS Word and embed spreadsheet
Message
 
À
26/09/2000 11:13:16
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00420953
Message ID:
00421398
Vues:
22
>Can somebody help how to update a Word doc. with an embed spreadsheet? Excel object is not linked.

This one's a bit tricky, but with enough playing, you can get it to work. Warning: it is temperamental, but stick with it!

To test this, I created a worksheet that looks like:
A 1
B 2
C 3

I highlighted that range of cells, copied them, then did Paste Special into Word, using Paste, not Paste Link.

Assumptions: oDoc is your document object and it's the first shape in the document.

First, you have to tell the spreadsheet object that you want to work with it. Each Shape with OLE capability has an OleFormat object to access those features. One of the methods is Activate(), which causes invokes the inplace editing UI:

oDoc.Shapes(1).OleFormat.Activate

Now that it's active, you can use the Object property to access all of the properties and methods from Excel. In my tinkering, I found I had to use the Application object to get this to work. I'm not at all sure of whether the Shape's Object property points to the Application, a Workbook, a Worksheet, or something else, so using the Application object gets you working on the proper kind of object.

To change B1's value to 200 (from the 1 shown above), give:
oDoc.Shapes(1).OleFormat.Object.Application.Range("B1").Value = 200

I've now played around with this for all of twenty minutes...there's a lot more to know about this, but at least it gets you started.

Good luck!

- della Martin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform