[VBA] Positioning Chart in Powerpoint after copy pasting from Excel

sanfrandear

New Member
Joined
Aug 20, 2019
Messages
4
Hi, I'm not sure how to refer to a picture of a chart that was copied from excel and pasted into powerpoint. The macro copies 4 charts in total and pastes them into one slide. I looked at the selection panel and they are named Picture 1, Picture 2, Picture 3 and Picture 4. I tried referring to last pasted picture as an activeshape, but it doesn't work.

Code:
oCHT1.CopyPicture   'ActiveChart.ChartArea.Copy
   activeSlide.Shapes.Paste
   
   With activeshape
    .Height = 28.35 * 5 ' resize
    .Width = 28.35 * 11  ' resize
    .Top = 28.35 * 0.75    ' reposition
    .Left = 28.35 * 5.2   ' reposition
    End With
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,211
To refer to the last pasted picture, try...

Code:
    With activeSlide
        With .Shapes(.Shapes.Count)
            .Height = 28.35 * 5 ' resize
            .Width = 28.35 * 11  ' resize
            .Top = 28.35 * 0.75    ' reposition
            .Left = 28.35 * 5.2   ' reposition
        End With
    End With
Hope this helps!
 

Watch MrExcel Video

Forum statistics

Threads
1,102,778
Messages
5,488,826
Members
407,658
Latest member
Arias610

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top