NetOfficeFw / Samples

🎓 Sample projects using NetOffice libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saving as PowerPoint 3, 4, or 95 file is not supported in this version of PowerPoint

leegean opened this issue · comments

当我使用NEtOFficeFw提供方法将一个pptx格式的文件转换成pdf时,出现“”Saving as PowerPoint 3, 4, or 95 file is not supported in this version of PowerPoint“的错误提示.

源文件是pptx格式,安装的office办公套件是PowerPoint 2016.

测试代码如下:

private static void ConvertPresentationToPdf()
        {
            NetOffice.PowerPointApi.Application application = new NetOffice.PowerPointApi.Application();
            application.DisplayAlerts = PpAlertLevel.ppAlertsNone;

            Presentation presentation = application.Presentations.Open("E:\\360MoveData\\Users\\leegean\\Documents\\演示文稿1.pptx", false);
            presentation.SaveAs("E:\\360MoveData\\Users\\leegean\\Documents\\ppt2.pdf", PpFixedFormatType.ppFixedFormatTypePDF);

            // close Excel and release application instance and any child objects
            // (workbooks in this case)
            application.Quit();
            application.Dispose();

        }

异常消息如下:

NetOffice.Exceptions.MethodCOMException (0x80004005): Failed to proceed Method on PowerPoint.Presentation=>SaveAs.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Runtime.InteropServices.COMException (0x80048240): Presentation.SaveAs : Invalid request.  Saving as PowerPoint 3, 4, or 95 file is not supported in this version of PowerPoint.
   --- End of inner exception 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.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at NetOffice.Invoker.Method(ICOMObject comObject, String name, Object[] paramsArray)
   at NetOffice.Invoker.Method(ICOMObject comObject, String name, Object[] paramsArray)
   at NetOffice.CoreMethodExtensions.ExecuteMethod(Core value, ICOMObject caller, String name, Object[] paramsArray)
   at NetOffice.CoreMethodExtensions.ExecuteMethod(Core value, ICOMObject caller, String name, Object argument1, Object argument2)
   at NetOffice.PowerPointApi._Presentation.SaveAs(String fileName, Object fileFormat)
   at WpfApp1.MainWindow.ConvertPresentationToPdf() in D:\RiderProjects\WpfApp1\WpfApp1\MainWindow.xaml.cs:line 57
   at WpfApp1.MainWindow.<>c.<ButtonBase_OnClick>b__1_0() in D:\RiderProjects\WpfApp1\WpfApp1\MainWindow.xaml.cs:line 45
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

演示文稿1.pptx

As the message says, those file formats are not supported by your PowerPoint.