Editing an Embedded Excel Worksheet

K

Keith

This one has perplexed me ...

I'm automating Word from C# under VS .Net 2005. Everything about automating
Word has been straightforward. I have an embedded Excel document (not
linked) in the Word document that I'd like to change a single cell on. The
cell is on the first and only worksheet. Does anyone have any pointers? I
cannot seem to find any documention.
 
H

Helmut Weber

Hi Keith,

see:
http://tinyurl.com/r8eq3

To overcome the sendkeys problems mentioned there,
here is a very simplified example from the book, Cindy referred to:

Sub test40012()
Dim oShp As Word.InlineShape
Dim olef As Word.OLEFormat
Set oShp = ActiveDocument.InlineShapes(1)
Set olef = oShp.OLEFormat
ChangeExcel olef
End Sub
Sub ChangeExcel(olef As Word.OLEFormat)
Dim xlApp As Excel.Application
Dim xlWrk As Excel.Workbook

olef.DoVerb verbindex:=wdOLEVerbOpen
Set xlWrk = olef.Object
Set xlApp = xlWrk.Application
xlWrk.ActiveSheet.Cells(1, 1).Value = "1"
xlApp.Quit
Set xlApp = Nothing

End Sub

The book is so far available only in German.
Meister, Gahler, Freßdorf, Jamieson:
Word-Programmierung Das Handbuch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top