I am currently exporting a data table and a chart to a word document from my excel file with this code:
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?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
Any ideas ttt
Please, does anyone have any ideas...
ttt, please any help
Try this modification to the end of your code.
Also, you may need to rethink those height and width values as the shape is in points not cm's.With wdInfo .PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _ wdFloatOverText, DisplayAsIcon:=False End With With wdDoc.Shapes(wdDoc.Shapes.Count) .LockAspectRatio = msoFalse .Height = 3.89 .Width = 7.22 End With
Height= 110.6342
Width = 204.6614
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks