none
Application.Presentations.Open() generating exception Error Code: -2147467259. Automation rights are not granted. RRS feed

  • Question

  • Application.Presentations.Open('file.pptx', true) line generates exception when called from my addin. Actually I had developed an addin which is having a logic to copy some shapes from another pptx file which is playing a role of a template for my addin. On click of a button, logic has been written to open the file programmatically and copy the shape from the presentation and paste to the target presentation.

    The functionality seems to work fine but as and when any pptx file(whether related to addin or not) is previewed in the preview mode of window 7 explorer window, my addin start raising below mentioned exception

    Error  Code: -2147467259. Presentation (unknown member) : Invalid request.  Automation rights are not granted.

    I had tried Application.AutomationSecurity but its not working or I'm not sure that I'm making some mistake in implementing the same or there is some other solution to this problem.

    Waiting for reply.

    Monday, November 28, 2011 4:34 PM

Answers

  • Hi Xeng

    The reason you'd get this error is logical enough: in order to show a preview, Windows Explorer probably has a file-lock on the file.

    I think the best course of action would be to trap the error (try...catch) and inform the user he first needs to exit the view of this file in Windows Explorer before the functionality can be used.

    Another possibility would be to store these "template" files somewhere where the user can't view them, so the error can't occur to begin with. If you feel the user should be able to look at them, one option would be to create dupicate files: one for viewing, one for the actual "work".

    Although I think it would be much better if you could present a "preview" of the Shapes in a custom task pane so that the user wouldn't have to switch between windows.


    Cindy Meister, VSTO/Word MVP
    Wednesday, November 30, 2011 8:24 AM
    Moderator

All replies

  • Hi Xengg,

     

    Thanks for posting in the MSDN Forum.

     

    I would recommend you feed back this issue to connect set. It seems need further research by the experts of PowerPoint.

     

    If you don’t know how to submit your feedback, please feel free to let me know. I will submit it for you.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, November 30, 2011 3:51 AM
    Moderator
  • Hi Xeng

    The reason you'd get this error is logical enough: in order to show a preview, Windows Explorer probably has a file-lock on the file.

    I think the best course of action would be to trap the error (try...catch) and inform the user he first needs to exit the view of this file in Windows Explorer before the functionality can be used.

    Another possibility would be to store these "template" files somewhere where the user can't view them, so the error can't occur to begin with. If you feel the user should be able to look at them, one option would be to create dupicate files: one for viewing, one for the actual "work".

    Although I think it would be much better if you could present a "preview" of the Shapes in a custom task pane so that the user wouldn't have to switch between windows.


    Cindy Meister, VSTO/Word MVP
    Wednesday, November 30, 2011 8:24 AM
    Moderator