Consulting

Results 1 to 2 of 2

Thread: Powerpoint macro to attach an object

  1. #1
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    1
    Location

    Powerpoint macro to attach an object

    Hello. I am new to this forum, new to Powerpoint, and especially new to Powerpoint macros and now sadly Record macro is gone.

    Basically I need to attach a pdf to a page (step one), resize it (step two), and then open a new page (step three) and do the same again until I attach my five pdfs to five pages. I need to attach the same reports updated monthly. Rather than manually attach the reports I would like to do this automatically.

    I believe I can do step two (thanks to a short and sweet web land tutorial - ActiveWindow.Selection.ShapeRange.Width = 500) and step three (thanks to VBA Express site: Set Sld = Pre.Slides.Add(Index:=Pre.Slides.Count + 1, Layout:=ppLayoutText) but not step one.

    In Excel the code for step one would be

    ActiveSheet.OLEObjects.Add Filename:="Q:\GPMS\LFA\Queries\AC Query Results\Top 50 Clients Pie.pdf", Link:=False, DisplayAsIcon:=False

    However just replacing ActiveSheet with ActivePresentation does not seem to work in Powerpoint as there is not an OLEObjects choice.

    Does anyone have the powerpoint vba code to do this or have any other suggestions?

    Thanks

    Leah

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    This should give you a start:

    You can add the size and position when you add the object

    [vba]Sub add_pdf()
    Dim osld As Slide
    Set osld = ActivePresentation.Slides(1)
    osld.Shapes.AddOLEObject Left:=100, Top:=10, Width:=300, Height:=400, FileName:="C:\Users\John\Desktop\test.pdf"
    End Sub[/vba]
    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
  •