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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Status
Not open for further replies.

Forum statistics

Threads
1,223,716
Messages
6,174,069
Members
452,542
Latest member
Bricklin

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