Hi macropod, thanks so much for the response. I will admit that I am the worst type of programmer (IT exec playing as required to get reports out) so I am happy to hear any feedback, good or bad.
To answer your question, the process is to select a range in excel that contains the table data and then do a search for a placeholder in the word document. For example:
Range("dep_comparison_table").Copy
wrdObj.Selection.Find.Text = "<dep_comparison_table>"
Call FormatPaste
wrdObj.Selection.MoveLeft Unit:=wdCharacter, Count:=20
wrdObj.Selection.Tables(1).AllowAutoFit = False
wrdObj.Selection.Tables(1).PreferredWidth = wrdObj.CentimetersToPoints(18.4)
Sub FormatPaste()
wdFind.Replacement.Text = ""
wdFind.Forward = True
wdFind.Wrap = wdFindContinue
wdFind.Execute
Call CheckClipBrd
wrdObj.Selection.Paste
CutCopyMode = False
End Sub
After all the tables are copied the tables are formatted with the following:
For Each Table In wrdDoc.Tables
Table.Select
For i = 1 To Table.Rows.Count
Table.Rows(i).Range.ParagraphFormat.KeepTogether = True
If i < Table.Rows.Count Then
Table.Rows(i).Range.ParagraphFormat.KeepWithNext = True
End If
Next i
Next Table
|