I have an excel workbook where a number of charts and tables are copied into word. Dotted through the word document there are several single cell word tables which are used to reference where each excel object needs to be pasted. The simplest way I have found to do this is by copying the excel data as a picture and pasting into the correct table in word. The code works fine,
The one small annoyance is that the pictures aren't centre aligned within the tables even though the tables have centre alignment set in the word template. It is necessary at the end to go through the document and for each picture (embedded in each table) the user has to Format > Align > Align Centre to correct.
Below is a sample of the code used to copy the pictures over.
'Copy Excel Table Range for requirements
r = 0
While Worksheets("requirements").Cells(26 + r, 2).Value <> ""
r = r + 1
Wend
Worksheets("Requirements").Range("B5:J" & (26 + r - 1)).CopyPicture
'Paste Table into MS Word
myDoc.Tables(1).Range.Select
myDoc.Tables(1).Range.PasteSpecial _
Link:=False, _
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdFloatOverText, _
DisplayAsIcon:=False
'Placement:=wdInLine, _
'Autofit Table so it fits inside Word Document (MK - I can't see any difference this makes but plese check)
Set WordTable = myDoc.Tables(1)
WordTable.AutoFitBehavior (wdAutoFitWindow)
'Copy Excel Table Range
Worksheets("Portfolio Structure").Range("D2:K62").CopyPicture
'Paste Table into MS Word
myDoc.Tables(2).Range.Select
myDoc.Tables(2).Range.PasteSpecial _
Link:=False, _
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdFloatOverText, _
DisplayAsIcon:=False
'Placement:=wdInLine
Any ideas? Thanks
The one small annoyance is that the pictures aren't centre aligned within the tables even though the tables have centre alignment set in the word template. It is necessary at the end to go through the document and for each picture (embedded in each table) the user has to Format > Align > Align Centre to correct.
Below is a sample of the code used to copy the pictures over.
'Copy Excel Table Range for requirements
r = 0
While Worksheets("requirements").Cells(26 + r, 2).Value <> ""
r = r + 1
Wend
Worksheets("Requirements").Range("B5:J" & (26 + r - 1)).CopyPicture
'Paste Table into MS Word
myDoc.Tables(1).Range.Select
myDoc.Tables(1).Range.PasteSpecial _
Link:=False, _
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdFloatOverText, _
DisplayAsIcon:=False
'Placement:=wdInLine, _
'Autofit Table so it fits inside Word Document (MK - I can't see any difference this makes but plese check)
Set WordTable = myDoc.Tables(1)
WordTable.AutoFitBehavior (wdAutoFitWindow)
'Copy Excel Table Range
Worksheets("Portfolio Structure").Range("D2:K62").CopyPicture
'Paste Table into MS Word
myDoc.Tables(2).Range.Select
myDoc.Tables(2).Range.PasteSpecial _
Link:=False, _
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdFloatOverText, _
DisplayAsIcon:=False
'Placement:=wdInLine
Any ideas? Thanks