Resize a picture of excel chart and paste into word

Status
Not open for further replies.

edwardj3

New Member
Joined
Jan 16, 2018
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi,

Hope you can help. My VBA code copies excel charts and then pastes into word doc which has bookmarks. How would I resize the copied chart after it is copied so that it will fit in the area of the doc?

Sub Chart_copy()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdRng As Word.Range


' bail out if no active chart
'If ActiveChart Is Nothing Then
'MsgBox "Select a chart and try again!", vbExclamation, "Export Chart To Word"
'Exit Sub
'End If

' get Word application if it's running
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
On Error Resume Next

If wdApp Is Nothing Then
' word not running so start it and create document
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add
Else
If wdApp.Documents.Count > 0 Then
' get active document
Set wdDoc = wdApp.ActiveDocument
Else
' no active document so create one
Set wdDoc = wdApp.Documents.Add
End If
End If


Set wdRng = wdDoc.Bookmarks("Bookmark1").Range

' copy chart
'ActiveChart.ChartObjects("Chart 2").Copy

Sheets("worksheetname").ChartObjects("Chart 2").Chart.ChartArea.Copy

' paste chart
wdRng.PasteSpecial _
Link:=False, _
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, _
DisplayAsIcon:=False

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Status
Not open for further replies.

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top