I am currently exporting a data table and a chart to a word document from my excel file with this code:
Sub XLtoWord()
Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet
Dim wdInfo Word.Range
Dim sTemps As String
Dim myNamed As Excel.Range
Dim myNamedChart As Excel.ChartArea
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
sTemps = "\\My\Documents\Work Graphs Template.docm"
Set wdDoc = wdApp.Documents.Open(sTemps)
Set myNamed = Sheets("EU History").Range("Table1")
Set wdInfo= wdDoc.Goto(what:=wdGoToBookmark, Name:="Table1")
myNamed.Copy
wdInfo.PasteSpecial link:=False, _
DataType:=2, _
Placement:=0, DisplayAsIcon:=False
ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.ChartArea.Copy
Set wdInfo= wdDoc.Goto(what:=wdGoToBookmark, Name:="Chart1")
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 3.89
.ShapeRange.Width = 7.22
End With
My issue is that I can't seem to resize the chart from within excel. I probably could do inside word once the chart is pasted, but I would rather leave my code inside excel. The .shaperange... does not have an effect on the chart size inside word. Any ideas?
Bookmarks