I am trying to copy a table from an excel sheet and paste it into a word document. I have no problem copying the table, but I cannot get the table to center on the word document page. I am very unfamiliar with Word VBA. Can anyone help?
(Select and copy the table in excel)
(xlRng - an Excel range object)
With ActiveSheet
.
.(determines the range of the table)
.
Set xlRng = Range(.Cells(1, 1), .Cells((V - 1), 8))
xlRng.Copy
End With
(Paste it onto Word and hopefully center it)
(oWdoc - a word document object)
oWdoc.Sections(1).Range.Paste
With Selection.Tables(1).Rows <-- Crashes here
.LeftIndent = 0
.Alignment = wdAlignRowCenter
'or set whichever alignment you want
End With
(Select and copy the table in excel)
(xlRng - an Excel range object)
With ActiveSheet
.
.(determines the range of the table)
.
Set xlRng = Range(.Cells(1, 1), .Cells((V - 1), 8))
xlRng.Copy
End With
(Paste it onto Word and hopefully center it)
(oWdoc - a word document object)
oWdoc.Sections(1).Range.Paste
With Selection.Tables(1).Rows <-- Crashes here
.LeftIndent = 0
.Alignment = wdAlignRowCenter
'or set whichever alignment you want
End With