Consulting

Results 1 to 2 of 2

Thread: Shape sizing problems

  1. #1

    Thumbs down Shape sizing problems

    I am having trouble with sizing pasted objects inside power point.
    My code copies two excels ranges and pastes them into power point.
    I have two problems

    1) Sizing the objects is ALL OVER THE PLACE. If I change the width on Object 3 from 190 to 200, the shape goes from smaller than half the slide to well outside the borders. If I change the width from 100 to 150, there is almost no change. Also, changing the Height still affects the width greatly.
    This makes me think that LockAspectRatio=msoFalse is not working.
    Also, I am not sure but I think having multiple shapes to resize is interfering as well.

    2) How can I do a regular paste instead of paste special. It always causes an error when I attempt to do that.

    [VBA]

    Sub PptProblems()

    Dim pptApp As PowerPoint.Application
    Dim pptPres As PowerPoint.Presentation
    Dim pptSlide As PowerPoint.Slide
    Dim pptShape As PowerPoint.Shape
    Dim ind_CY As Excel.Range, tbl_ind_CY
    Set ind_CY = Sheets("PC Summary").Range("ind_CY")
    Set tbl_ind_CY = Sheets("PC Summary").Range("tbl_ind_CY")
    Set pptApp = New PowerPoint.Application

    RangeLink = True

    pptApp.Presentations.Add
    pptApp.Visible = msoTrue


    pptApp.ActivePresentation.Slides.Add 1, ppLayoutBlank

    ThisWorkbook.Worksheets("PC Summary").Activate
    ind_CY.Copy

    pptApp.ActivePresentation.Slides(1).Shapes.PasteSpecial(ppPasteShape, link:=RangeLink).Select

    ThisWorkbook.Worksheets("PC Summary").Activate
    tbl_ind_CY.Copy ' copy an Excel range

    pptApp.ActivePresentation.Slides(1).Shapes.PasteSpecial(ppPasteShape, link:=RangeLink).Select 'Special ppPasteEnhancedMetafile

    With pptApp.ActivePresentation.Slides(1).Shapes("Object 2")
    .LockAspectRatio = msoFalse
    .Left = 8
    .Top = 2
    .Width = 200
    .Height = 35
    End With


    With pptApp.ActivePresentation.Slides(1).Shapes("Object 3")
    .LockAspectRatio = msoFalse
    .Left = 0
    .Top = 50
    .Width = 200
    .Height = 140
    End With


    RangeLink = False



    End Sub

    [/VBA]


    I am pretty good at programming in Excel, but PowerPoint remains elusive. And I was thinking it would be easier!

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Without seeing your excel it's not easy to say what is being pasted. If you are opasting a link then it will be an excel object and lockaspectratio will not apply - it is always true.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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