Results 1 to 2 of 2

Thread: Resizing Shapes between the Subtitle and Footer of Powerpoint Slides

  1. #1

    Resizing Shapes between the Subtitle and Footer of Powerpoint Slides

    Is there a way to resize shapes(pictures,tables,charts) pasted from an Excel Worksheet to Powerpoint slides, so that each shape is resized relative to it's original dimensions (LockAspectRatio=True) and placed exactly between a Slide's SubTitle and Footer and centered horizontally?

    The Shapes may be of varying sizes i.e. sometimes very small or sometimes greater than the dimensions of the Slide. Therefore the criteria is to resize them (without distorting) to fit nicely between the Subtitle and footer and horizontally center-aligned.

    Is this possible using Excel VBA?

    Below logic is not working correctly.

    Sub ResizeShapesInSlide()
    Dim L#, T#, W#, H#, SlideCnt%, i%
    Dim sHeight#, sWidth#
    Dim oSlide As Slide, oShp As Shape
    SlideCnt = ActivePresentation.Slides.Count
    For i = 1 To SlideCnt
        Set oSlide = ActivePresentation.Slides(i)
        With oSlide
            ' get Slide height & width
            sHeight = ActivePresentation.PageSetup.SlideHeight
            sWidth = ActivePresentation.PageSetup.SlideWidth
            Set oShp = .Shapes("Picture 1")
            With oShp
                .LockAspectRatio = msoTrue
                ' resize if image larger than Slide dimensions
                If .Width >= sWidth Then .Width = sWidth - oSlide.Shapes("SubTitle").Left
                If .Height >= sHeight Then .Height = sHeight - oSlide.Shapes("Footer").Top
    '            L = .Left: T = .Top: W = .Width: H = .Height
                ' Set shape Top to SubTitle Top + Height
                .Top = (oSlide.Shapes("SubTitle").Top + oSlide.Shapes("SubTitle").Height) + 5
                ' Initially set Shape to SubTitle Left
                .Left = oSlide.Shapes("SubTitle").Left
                 ' now adjust Shape height till Footer Top
                .Height = .Height - (sHeight - oSlide.Shapes("Footer").Top - 5)
                ' finally center shape horizontally
                .Left = (sWidth - .Width) / 2
            End With
        End With
    Next i
    End Sub

  2. #2
    VBAX Wizard
    Apr 2007
    The only slide layout that has a Subtitle placeholder (ppPlaceholderSubtitle) right out of the box is the Title layout


    Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts