Modifying excel table

G

George Perchette

Hi

I have word document with an embedded*
excel-table I should modify a text in Cell X
by VBA.

*no excel-document; just an excel-table

How can I do this?

Thanks for any help and Best Regards, George
 
H

Helmut Weber

Hi George,
like that:
Sub ExcelinWord()
Dim objOLE As Word.OLEFormat
Dim objXL As Object
Set objOLE = ActiveDocument.Shapes(1).OLEFormat
' your shape number instead of 1
objOLE.Activate
Set objXL = objOLE.Object
With objXL.ActiveSheet
.Cells(1, 1).Value = "Test 1"
.Cells(1, 2).Value = "Test 2"
End With
End Sub
Greetings from Bavaria
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
G

George Perchette

Dear Helmut

Thanks for your help.

Your code worked fine, when I used InlineShapes(1) instead
of Shapes(1).

Is this, because my code is used in Word 2000 and yours
would be the appropriate for Word XP?

Thanks for a short answer and - again - for your help.

Best Regards, George
 
H

Helmut Weber

Hi George,
there are shapes and inlineshapes and subtypes of shapes.
Whether an inserted object is "inline" or not
depends on the options you choose when inserting,
it has nothing to do with word versions.
As I got a German version, I can't say, what's the
option in English, that results in an inlineshape.
But I think, this could be the default option.
If you record inserting, you will see, that the
decisive property is Anchor:=Selection.Range (inline).
If this property is missing, you got a shape.
AFAIK
Greetings from Bavaria, Germany
Helmut Weber
 
H

Helmut Weber

Just saw it,
your email address seems to be from Switzerland.
"Über den Text legen" in Word 97 -> shape
else inlineshape
Grüezi
HW
 
G

George Perchette

And ...

....how to go back to the word document?
Sorry, I'm stuck with these kind of objects...

Thanks for your help and Best Regards, George
 
H

HElmut Weber

SendKeys "{ESC}"
Couldn't make up another solution.
There must be something better.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
 
G

George Perchette

Dear Helmut

You have been a great help; thanks for all
the information and your time!

Best Regards and many thanks, George
 

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