Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AciveWindow.ScrollColumn / Excel file embedded in word Werner Rohrmoser Excel Programming 0 April 17th 08 05:20 PM
Editing embedded Word file in Excel JUMPS to top Steve Brewster Excel Discussion (Misc queries) 0 September 12th 06 04:12 PM
Problem opening Excel file 1 time with embedded Word objects [email protected] Excel Programming 0 August 3rd 05 08:47 PM
Embedded word doc changed to image-need to change back to word. cflores Excel Discussion (Misc queries) 0 January 23rd 05 06:45 AM
Excel file embedded in Word doc--limitations of work area Winekno Excel Programming 2 April 1st 04 05:08 PM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"