• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to RESIZE Charts while copying from Excel into Word?

Rahul Agarwal

New Member
I have to create a macro for exporting charts of different dimensions in excel files into a word documentation. By using the below code charts are copying but with different dimensions. suggest a working code for the required query.


Code:
'Copying chart and selecting bookmark in activedocument

ActiveDocument.Bookmarks(BM_name).Select

sheet.Sheets(Tab_name).ChartObjects(Chart_name).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture


'Pasting of selected chart
Selection.Paste
   
    With ActiveDocument
        .InlineShapes.Height = 200
        .InlineShapes.Width = 200
    End With
 
Try:
Code:
sheet.Sheets(Tab_name).ChartObjects(Chart_name).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
'Pasting of selected chart
With ActiveDocument.Bookmarks(BM_name).Range
  .Paste
  .End = .End + 1
  With .InlineShapes(1)
    .LockAspectRatio = True
    .Height = 200
  End With
End With
 
Try:
Code:
sheet.Sheets(Tab_name).ChartObjects(Chart_name).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
'Pasting of selected chart
With ActiveDocument.Bookmarks(BM_name).Range
  .Paste
  .End = .End + 1
  With .InlineShapes(1)
    .LockAspectRatio = True
    .Height = 200
  End With
End With

WOW!!!! Thanks a lot @macropod it worked correctly!!
 
Back
Top