Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post: Embedded Word File
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post: Embedded Word File
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 "Troubled User" wrote: 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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post: Embedded Word File
Thank you VERY much. I will try a little later tonight and let you know if I
have any problems. "Joel" wrote: 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 "Troubled User" wrote: 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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post: Embedded Word File
Joel,
Your code worked great with a couple of minor modifications to adjust for length constraints (I looped multiple times). So thank you very much. The final problem I am having is determining if the text I moved is bold/underlined/etc. I have been trying to adapt code that I run against Excel textboxes such as: For Counter1 = 1 To Source1.Characters.Count If Source1.Characters(Counter1, 1).Font.Bold Then Target1.Characters(Counter1, 1).Font.Bold = True End If I have tried numerous variations to get at the individual characters within the Word tables, such as: MsgBox (tbl.cell(2, 1).Range.Characters(1, 1)) MsgBox (tbl.cell(2, 1).Range.Text.Characters(1, 1)) MsgBox (tbl.cell(2, 1).Characters(1, 1)) And on and on. I don't know how to get at the characters within the table object. Any help you could provide would be greatly appreciated. Thanks again! "Troubled User" wrote: Thank you VERY much. I will try a little later tonight and let you know if I have any problems. "Joel" wrote: 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 "Troubled User" wrote: 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
AciveWindow.ScrollColumn / Excel file embedded in word | Excel Programming | |||
Editing embedded Word file in Excel JUMPS to top | Excel Discussion (Misc queries) | |||
Problem opening Excel file 1 time with embedded Word objects | Excel Programming | |||
Embedded word doc changed to image-need to change back to word. | Excel Discussion (Misc queries) | |||
Excel file embedded in Word doc--limitations of work area | Excel Programming |