Share via

Insert PDF OLE object into PowerPoint slide using VBA.__

Anonymous
2011-02-03T00:00:39+00:00

I have followed the documentation perfectly and am convinced that one cannot insert a PDF file as an OLE object into a slide using VBA.

Each time I get an automation error, even though I can insert it manually. I am including all of the arguments to mySlide.shapes.addOLEObject. I am using the full file name and not the classname.

I do a lot of slide creation using VBA so I am n ot new to this. I am using the Office 2007 version of ppt. Any thoughts?

Thanks,

karl


karl

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

5 answers

Sort by: Most helpful
  1. Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
    2011-02-04T15:50:37+00:00

    Another suggestion from a friend at MS:  check to see if you have the Send to Bluetooth add-in installed; it comes by default with some PCs that have Bluetooth and a trial of Office installed.  Uninstalling the Office trial doesn't remove the Bluetooth add-in's registry entries, so it'd proably survive Office reinstall and other nuclear attacks.  Cybercockroach of sorts. 

    It seems to be at the root of various problems; try googling it.


    Steve Rindsberg PowerPoint MVP

    PowerPoint FAQ

    PPTools Add-ins for PowerPoint

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-02-03T19:24:55+00:00

    I should explain that I am running the code from a Word doc that has a "very rich"  .DOT -- in code, that is.

    My App builds PowerPoint presentations from structured content in a Word doc. I checked for acroread in processes and found nothing, there is also only one instance of powerpoint running.

    I get this message also,

    Method "addOLEObject of object "Shapes" failed.

    Whenever I use link:=msoFalse I get an object the size of my rectangle (placeholder) with the name of the file in enormous letters -- what I want is the image of the PDF document - first page.

    I am ready at this point to start trying to trick it in some way -- perhaps a graphic to which I assign a hyperlink.

    karl


    karl

    Was this answer helpful?

    0 comments No comments
  3. Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
    2011-02-03T18:46:59+00:00

    Thanks for the extra info, Karl.

    I was doing it w/ link:=msoFalse but doubt that that matters.

    I did some other tests and found that the same code fails with Word DOC files but works with PPT, PPTX and XLS files (in 2007, that is).

    Then I figured I'd doublecheck the Reader version on the 2007 PC and fell right on top of a large AHA.

    Reader wouldn't start on its own.  Tried a couple times.  Nada.

    So I checked Task Manager and found a couple instances of Reader AND two instances of POWERPNT.EXE running; obviously, there shouldn't have been more than one.  I quit PPT then killed all the PPT and Reader processes.  Re opened the PPT file with my code in it and bingo, it inserted a PDF object.

    Linked or embedded ... both work.

    Word DOCX or DOC files too. 


    Steve Rindsberg PowerPoint MVP

    PowerPoint FAQ

    PPTools Add-ins for PowerPoint

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-02-03T16:54:30+00:00

    Hi Steve,

    I am using XP SP 3, PowerPoint Version 12.0 Build 6211, Adobe Reader ver. 8.1.3.

    This is the line of code that fails

    Set myShape = mySlide.Shapes.AddOLEObject(Left:=rectShape.L, Top:=rectShape.T, width:=rectShape.W, height:=rectShape.H, FileName:=strName, link:=msoTrue)

    where strName is the full path name.

    Error is

    Automation Error

    Unspecified Error

    That's about it. I also have an installation of Office 2003 on this computer and I will try it using Powerpoint 2003 to see if that makes a difference.

    Thanks.

    karl


    karl

    Was this answer helpful?

    0 comments No comments
  5. Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
    2011-02-03T15:56:01+00:00

    The best way to get help with code is always to

    • post the code that's giving you trouble
    • indicate the line or lines that provoke errors
    • supply the exact text of the error message

    But in this case, I think you've run into a bug in PPT.  Here's some example code that works in 2003 and 2010 here.

    It bellyflops in 2007.  Welcome to the bugfarm.  BTW, both the systems where it works here are XP, one with Adobe Reader 8, one with Adobe Reader 9.  The 2007/Fail happens on Vista with Adobe Reader 8.  I've reported this to MS but would like to know your Windows and Adobe Reader version; the more data we can supply, the better.  Also, what SP level is your Office 2007 install up to?  Mine's SP2.

    Sub PopAPDF()

    Dim oSh As Shape

    Dim oSl As Slide

    Dim sFileName As String

    sFileName = "c:\temp\somefile.pdf"

    Set oSl = ActivePresentation.Slides(1) ' or whatever you want

    ' Assuming it's a letter-sized/portrait PDF:

    Set oSh = oSl.Shapes.AddOLEObject(Left:=0, _

        Top:=0, _

        Width:=8.5 * 72, _

        Height:=11# * 72, _

        FileName:=sFileName, _

        Link:=msoFalse)

    End Sub


    Steve Rindsberg PowerPoint MVP

    PowerPoint FAQ

    PPTools Add-ins for PowerPoint

    Was this answer helpful?

    0 comments No comments