Thanks for the response! Worked...kinda. Here's what I ran into, the code stops executing and hangs up on the Set Document line. After further consideration and your showing me possibilities, I have a couple of additional assistance requests. I only presented part of the process because I was only thinking one direction. The actual process is that 1) I copy and paste data from columns 5 and 6 of the Word table to Excel table G and L, 2) I adjust the data and generate column M then 3) I copy and paste Excel G, L and M back to Word table into columns 5, 6 and 7 then 4) since each Word column has unique formatting (has tabs which I could not duplicate) I have to select the title for each column and format each column using the format painter. I tried using macro recording to accomplish this but to without success because it would only format the first cell in the table.
Word Table
- Generated from separate program but variable rows each time.
Request
1) Access the open instance of the word document...possibly have an error handler if it hangs up
2) Copy the data from Word table 1 columns 5 & 6 and paste in Excel table column G & L
3) Copy the data from Excel table columns G, L & M and paste into Word table 1 columns 5, 6 & 7.
4) Format Word table columns 5, 6 & 7 based on format of the table row 2 cells of each column.
Word Table 1
Sub Copy_CV()
Dim MaxVal As Long, C As Long
MaxVal = Worksheets("Prop").Application.Max(Columns(2))
C = MaxVal + 3
'open Word with COM and late binding and open document
Dim Word As Object, Document As Object, Table As Object
Set Word = CreateObject("Word.Application")
Set Document = Word.Documents.Open("c:\test\Test.rtf")
'get table
Set Table = Document.Tables(1)
'
Worksheets("Prop").Range("G4:G" & C).Select
Selection.Copy
Table.Cell(Row:=3, Column:=5).Range.Select
Word.Selection.Collapse
Word.Selection.PasteAndFormat (wdTableOverwriteCells)
'Copy ppa
Worksheets("Prop").Range("L4:L" & C).Select
Selection.Copy
Table.Cell(Row:=3, Column:=6).Range.Select
Word.Selection.Collapse
Word.Selection.PasteAndFormat (wdTableOverwriteCells)
'Copy klbs
Worksheets("Prop").Range("M4:M" & C).Select
Selection.Copy
Table.Cell(Row:=3, Column:=7).Range.Select
Word.Selection.Collapse
Word.Selection.PasteAndFormat (wdTableOverwriteCells)
'save and close document
Document.Save
Document.Close
Word.Quit
Set Table = Nothing
Set Document = Nothing
Set Word = Nothing
End Sub