Trying to Rescale images remotely in word from excel macro

Archie Smith 0 Reputation points
2023-01-27T16:24:48.3666667+00:00

For my company one of the processes is copying graphs from an Excel spreadsheet and pasting them into a word document. However, these graphs are pasted slightly too big and need to be descaled to 80% their original size. I'm trying to write a macro in excel that will copy these graphs, paste them in and then reduce their size in word. From research online this is what I have so far:

Sub ExportChartToWord()

    Dim WrdApp As Word.Application
    Dim WordDoc As Word.Document
    Dim Chrt As ChartObject

    Set WrdApp = New Word.Application
        WrdApp.Visible = True
        WrdApp.Activate

    Set WrdDoc = WrdApp.Documents.Add

    'chart 1
    Set Chrt = ActiveSheet.ChartObjects(1)
        Chrt.Chart.ChartArea.copy
    
    With WrdApp.Selection
        .PasteSpecial Link:=False, DataType:=15, Placement:=wdInLine, _
            DisplayAsIcon:=False
    End With
End Sub

For simplicity I have only included one of the 4 charts in the following code but the other 3 are just the same line of code.

I would be very greatful for any support I could get. it seems like a simple problem but I just cant work it out!

Thanks,

Archie.

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
591 questions
Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,300 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,496 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,294 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 109.8K Reputation points
    2023-01-27T21:54:12.02+00:00

    After pasting the first image, try executing a code like this:

    WrdDoc.InlineShapes(1).ScaleWidth = 80
    WrdDoc.InlineShapes(1).ScaleHeight = 80
    
    1 person found this answer helpful.
    0 comments No comments