none
Capturing Presentation FileName in BeforeSave event RRS feed

  • Question

  • PowerPoint does not provide an AfterSave event, only a BeforeSave event. I set the Cancel property to true and wrote my only FileSave dialog from which I capture the filename to save.

    I then execute a PowerPoint.Presentation.SaveAs(filename) but I get an error "Presentation (unknown member): Failed". The error code is -2147467259

    How can I capture the filename of a PPT presentation at it's saved location?

    Monday, July 22, 2013 7:30 PM

Answers

  • There are two events, PresentationBeforeSave and PresentationSave and unfortunately the BeforeSave event does not have an indicator that the event was triggered by a SaveAs. The importance of the indicator is to know if the user has actually changed the path and file name.

    What I do to get the path and file name is to trap the SaveAs action from the UI with this modification:

      <commands>
        <command idMso="FileSaveAs" onAction="ClkSaveAs" />
      </commands>
    

    The callback sets the Boolean value:

        Public Sub ClkSaveAs(ByVal control As Office.IRibbonControl, ByRef cancelDefault As Boolean)
            ThisAddIn.ClkedSaveAs = True
            ribbon.Invalidate()
            cancelDefault = False
        End Sub
    

    With that done, when the PresentationBeforeSave executes I know what I'm working with and I can take appropriate action with the Pres.FullName as required.

    Hope that helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Monday, July 22, 2013 8:21 PM
  • Hopefully this article will help you. It has a C# example.

    http://msdn.microsoft.com/en-us/library/office/bb462633%28v=office.12%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2


    Kind Regards, Rich ... http://greatcirclelearning.com

    Tuesday, July 23, 2013 11:34 AM

All replies

  • There are two events, PresentationBeforeSave and PresentationSave and unfortunately the BeforeSave event does not have an indicator that the event was triggered by a SaveAs. The importance of the indicator is to know if the user has actually changed the path and file name.

    What I do to get the path and file name is to trap the SaveAs action from the UI with this modification:

      <commands>
        <command idMso="FileSaveAs" onAction="ClkSaveAs" />
      </commands>
    

    The callback sets the Boolean value:

        Public Sub ClkSaveAs(ByVal control As Office.IRibbonControl, ByRef cancelDefault As Boolean)
            ThisAddIn.ClkedSaveAs = True
            ribbon.Invalidate()
            cancelDefault = False
        End Sub
    

    With that done, when the PresentationBeforeSave executes I know what I'm working with and I can take appropriate action with the Pres.FullName as required.

    Hope that helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Monday, July 22, 2013 8:21 PM
  • I'm sorry, I'm writing in C#. Can you explain this in those terms?

    PS: Thank you for your quick response.

    Monday, July 22, 2013 10:07 PM
  • Hopefully this article will help you. It has a C# example.

    http://msdn.microsoft.com/en-us/library/office/bb462633%28v=office.12%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2


    Kind Regards, Rich ... http://greatcirclelearning.com

    Tuesday, July 23, 2013 11:34 AM