Share via

Resizing and Positining Charts on a power point slide using VBA?

Anonymous
2012-01-30T22:41:46+00:00

Hello,

I got a .ppt with several slides. All the slides are ugual to each other.

In each slide there are 2 Chart (linked from different excel files).

What I need is to select those charts and todimension and to change position on the slide.

In other terms:

Slide:

Chart 1 as its size (1) and position (1)

Chart 2 as its size (2) and position (2)

Thne I need to repeat this istruction for all slides.

Thank you in advance for feedbacking.

Pomaker

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-01-31T01:44:06+00:00

This should get you started. It assumes that they are only 2 shapes per slide and it will resize and position the 1st two shapes on the slide. You can further edit the code to suit your purpose.

Sub ProcessAllSlides()

Dim sld As Slide

Dim Shp As Shape

For Each sld In ActivePresentation.Slides

    Call SetChartSizeAndPosition(sld.Shapes(1), 10, 10, 200, 200)

    Call SetChartSizeAndPosition(sld.Shapes(2), 310, 10, 200, 200)

Next

End Sub

Sub SetChartSizeAndPosition(Shp As Shape, Left As Single, Top As Single, Width As Single, Height As Single)

With Shp

    .Left = Left

    .Top = Top

    .Width = Width

    .Height = Height

End With

End Sub

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Steve Rindsberg 99,161 Reputation points MVP Volunteer Moderator
    2014-05-25T02:34:30+00:00

    While it won't resize every chart in the presentation automatically, my free PPTools StarterSet add-in includes a Place Exactly tool that will make this simpler.  You'd use it to first pick up the size/position of the chart you want to use as the standard, then select each add'l chart and click the "hammer" button to set its size/position to match the first.

    http://www.pptools.com/starterset/

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-05-23T08:28:24+00:00

    Hi Shyam,

    I find your solutions very useful.

    Is there any way to create an addin for powerpoint that resizes all charts in the current slide as per the properties of the selected chart.

    eg. I have 4 charts on a slide and I update one as per the requirements i.e. height, width, top, left, plotarea, legend, font, font color. Now I want all other charts in the slide to be setup with the same. so, i select the chart I have updated and run the addin that will copy the setting from my updated chart and apply to all the rest.

    is this possible?

    Was this answer helpful?

    0 comments No comments