none
For powerpoint Plugin SaveAs is pdf not working RRS feed

  • Question

  • Hi,

    I have written a plugin for powerpoint in VB.

    I am creating a Dialog in "PresentationBeforeSave"Event like Dim dlg As Office.FileDialog. when i am performing an action Save As pdf on powerpoint file then dlg.execute is not working.

    Similar kind of code is working perfectly for Word.

    I could see in the normal ppt file while doing SaveAs pdf it does some publishing operation.

    Query- Do we have some other event for this operation? Do i need to use some other Dialog ? Pleas help

    Thanks in advance.

    Wednesday, May 20, 2015 4:14 AM

Answers

  • Hi,

    >> when i am performing an action Save As pdf on powerpoint file then dlg.execute is not working.

    The file dialog is not working, Is there any error message ?

    Based on my understanding, you are going to save a PPT as a PDF file. Since you have used FileDialog object, have you add the Office library in the reference ?

    Either SaveAs Method or ExportAsFixedFormat method could save a PPT as a PDF. The following code you may could use as an reference.

    Private Sub cmdFileDialog_Click()
       Dim fDialog As Office.FileDialog
       Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
          fDialog.Title = "Save PDF file"
          fDialog.InitialFileName = "D:\MyTest.PDF"
          fDialog.Show
        ActivePresentation.ExportAsFixedFormat fDialog.InitialFileName, ppFixedFormatTypePDF
        'ActivePresentation.SaveAs fDialog.InitialFileName,ppSaveAsPDF, msoCTrue
           
    End Sub

    If it couldn’t help you, could you please share more information, like the error message or the code?

    Best Regards,

    Lan



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, May 21, 2015 4:58 AM
    Moderator
  • >> But i also want to handle SaveAs case for other extensions as well. for which i am trying to use fDialog.execute()

    For the other extensions you also could set the FilterIndex to set the format, then use execute method to save the file, the following code could be work for you. when the FilterIndex is 4, the file extention will be pdf.

    Sub t1()
    Dim fDialog As Office.FileDialog
       Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
          fDialog.Title = "Save PDF file"
          fDialog.InitialFileName = "MyPPT"
          fDialog.FilterIndex = 4
          fDialog.Show
          fDialog.Execute
    End Sub
    

    Hope this could help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Tuesday, June 2, 2015 3:19 AM
    Sunday, May 24, 2015 2:55 PM
    Moderator

All replies

  • Hi,

    >> when i am performing an action Save As pdf on powerpoint file then dlg.execute is not working.

    The file dialog is not working, Is there any error message ?

    Based on my understanding, you are going to save a PPT as a PDF file. Since you have used FileDialog object, have you add the Office library in the reference ?

    Either SaveAs Method or ExportAsFixedFormat method could save a PPT as a PDF. The following code you may could use as an reference.

    Private Sub cmdFileDialog_Click()
       Dim fDialog As Office.FileDialog
       Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
          fDialog.Title = "Save PDF file"
          fDialog.InitialFileName = "D:\MyTest.PDF"
          fDialog.Show
        ActivePresentation.ExportAsFixedFormat fDialog.InitialFileName, ppFixedFormatTypePDF
        'ActivePresentation.SaveAs fDialog.InitialFileName,ppSaveAsPDF, msoCTrue
           
    End Sub

    If it couldn’t help you, could you please share more information, like the error message or the code?

    Best Regards,

    Lan



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, May 21, 2015 4:58 AM
    Moderator
  • Hi Lan,

    Thanks a lot for your solution SaveAs PDF is working fine fine for me now with following statemtn.

    ActivePresentation.ExportAsFixedFormat fDialog.IntitalFileName, ppFixedFormatTypePDF


    But i also want to handle SaveAs case for other extensions as well. for which i am trying to use fDialog.execute()

    for the same dialog, you have mentioned above but execute statement is not working in this case and it is not giving any error for it just not saving the file.

    Please help me on it.

    Also do we have any Specific event for SaveAs PDF operation ? if there is any then also it will work for me.

    Thanks

    Friday, May 22, 2015 10:29 AM
  • >> But i also want to handle SaveAs case for other extensions as well. for which i am trying to use fDialog.execute()

    For the other extensions you also could set the FilterIndex to set the format, then use execute method to save the file, the following code could be work for you. when the FilterIndex is 4, the file extention will be pdf.

    Sub t1()
    Dim fDialog As Office.FileDialog
       Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
          fDialog.Title = "Save PDF file"
          fDialog.InitialFileName = "MyPPT"
          fDialog.FilterIndex = 4
          fDialog.Show
          fDialog.Execute
    End Sub
    

    Hope this could help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Tuesday, June 2, 2015 3:19 AM
    Sunday, May 24, 2015 2:55 PM
    Moderator
  • Hi Lan,

    Thanks for your solution but still my problem has not been resolved. Actually when i am initializing the dialog box like

    fDialog = Application.FileDialog(MsoFileDialogType.msoFileDialogSaveAs)

    while debugging i have checked debug information. under Application

    Message : "Exception has been thrown by the target of an invocation"

    HResult: -2147467259

    InnerException: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

    Sometimes this 

    "Could not load file or assembly 'Microsoft.CSharp' or one of its dependencies. The system cannot find the file specified."

    Stack Trace:

    at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Dynamic.IDispatchComObject.GetMembers(IEnumerable`1 names)

    I think i am missing on some Reference to add. Please help on it.

    Thanks


    Monday, May 25, 2015 10:40 AM
  • Hi Lan,

    In addition to above post i have added one refrence Microsoft.Office.Interop.Powerpoint is there any other reference needs to be added for dialog ?

    Thanks

    Monday, May 25, 2015 12:39 PM
  • Hi,

    >> In addition to above post i have added one refrence Microsoft.Office.Interop.Powerpoint is there any other reference needs to be added for dialog ?

    The reference Microsoft.Office.Interop.Powerpoint is OK, Application.FileDialog Property (PowerPoint) represents a single instance of a file dialog box. You could get more information here.

    https://msdn.microsoft.com/en-us/library/office/ff744016.aspx

    Best Regards,

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 28, 2015 2:03 AM
    Moderator