none
replace embedded PDF document content RRS feed

  • Question

  • I have a simple vsto addin that can add a PDF file to a slide in a presentation.  It adds it as an embedded object.   That's fine.   

    Subsequently i want to replace the content of the embedded object with a new version of the PDF file.

    Can't quite figure out how to do that. 

    Tried casting the shape.OleFormat.Object as IPersistFile, and then using the Load method to load the new version of the file.     That seems to wipe out the picture of the pdf content that shows in design and slide show modes.  It doesn't update it to be the new version of the PDF file.

    The other idea would be to delete the old PDF object and create a new one.  I'd have to preserve all of the placement and other properties that may have been set on the object.  Maybe that's an option?

    Any thoughts on how do accomplish this?

    Thanks

    roger


    roger reynolds

    Thursday, May 9, 2013 1:32 AM

Answers

  • Hi Roger

    It would help if you would show us the method you're using to embed the object...

    PowerPoint does support embedding objects with a link to the original file (test in the UI via Insert/Object/From file - you'll see a Link checkbox). I think that's the only way you'd be able to switch objects "simply".

    Otherwise, yes, you'd need to store all the relevant properties, delete the old, insert the new and format it.

    The only other possibility would be to perform the exchange on the closed file, leveraging the Open XML file format.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, May 9, 2013 6:51 AM
    Moderator
  • Hi Roger

    I apologize for the long delay in responding. I required some personal time and wasn't able to participate in the forums for a couple of weeks...

    The Shape object has a LinkFormat.Update method that should take care of updating any linked OLE objects.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, May 25, 2013 5:25 PM
    Moderator

All replies

  • Hi Roger

    It would help if you would show us the method you're using to embed the object...

    PowerPoint does support embedding objects with a link to the original file (test in the UI via Insert/Object/From file - you'll see a Link checkbox). I think that's the only way you'd be able to switch objects "simply".

    Otherwise, yes, you'd need to store all the relevant properties, delete the old, insert the new and format it.

    The only other possibility would be to perform the exchange on the closed file, leveraging the Open XML file format.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, May 9, 2013 6:51 AM
    Moderator
  • I embed like so:

      slide.Shapes.AddOLEObject(0, 0, 100, 100, FileName: path, Link: MsoTriState.msoFalse);

    where slide is the current slide and path is the full path to a temp PDF file that I delete after embedding.   

    I considered using a link instead, and may do that instead/as well, but then my question would instead be - how to update the link from my addin code.  There probably is a way to do that, since you can do it from the object properties dialog in the UI.   

    Tips on that much appreciated.

    Thanks



    roger reynolds

    Thursday, May 9, 2013 11:34 PM
  • Hi Roger

    I apologize for the long delay in responding. I required some personal time and wasn't able to participate in the forums for a couple of weeks...

    The Shape object has a LinkFormat.Update method that should take care of updating any linked OLE objects.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, May 25, 2013 5:25 PM
    Moderator