Re-Post: Embedded Word File

T

Troubled User

I have an Excel File that has an embedded Word File in it. The embedded Word
file contains a table with say 5 rows and 3 columns.

Additionally, in this file I have a text box (Textbox1). I am trying to
copy the contents of Textbox1 to Row 2, column 2 of the table within the
embedded Word file.

I have done a fair amount of copying between Textboxes/cells and Textbox to
Textbox, but I don't know how to reference this table and location in the
embedded Word file.

Any help is very appreciated.
 
J

Joel

I saw youor earlier posting but didn't have time to respond. This code
should work. Change "ABC" to read the data from your text box.

Sub gettable()

For Each obj In ActiveSheet.OLEObjects
If InStr(obj.progID, "Word.Document") > 0 Then
'open word document
obj.Activate

Set WordDoc = obj.Object.Application.ActiveDocument
MyRow = 2
MyCol = 2
For Each tbl In WordDoc.tables
tbl.cell(MyRow, MyCol).Range.Text = "ABC"
Next tbl

End If

Next obj

End Sub
 
T

Troubled User

Thank you VERY much. I will try a little later tonight and let you know if I
have any problems.
 

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