General information
Category:
COM/DCOM and OLE Automation
>>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
Main reason I did not link Excel was that I have to create a bunch of Word docs. so if I linked them to their spreadsheets then all the files would have the same chart form last Excel file. I decided to create a spreadsheet for every Word doc. which now have them linked and I dont have to update Word programmatically. I know this is not the best but I am running out of time.
Thanks for help,
Mark
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only