0

I am automating of ppt creation. The SaveAs method is throwing an exception. The exception message is:

Presentation (unknown member) : An error occurred while PowerPoint was saving the file.

Here is the screenshot

enter image description here

I can't locate the error code out of this. Can anybody help me in this?

Note: I am using Windows 7 - 64 bit

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
prabhakaran
  • 5,126
  • 17
  • 71
  • 107

1 Answers1

0

Before I give you some tips on getting that error code, here's something I found on Microsoft support website:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

Reference: http://support.microsoft.com/kb/257757 <- might be a good read. It may or may not be applicable to your situation.

To get the last error, you would use: System.Runtime.InteropServices.Marshal.GetLastWin32Error()

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getlastwin32error.aspx

Since you're trying to get the code, this may very well work:
System.Runtime.InteropServices.Marshal.GetExceptionCode()

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getexceptioncode(v=vs.110).aspx

You might have to use PInvoke:

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.setlasterror.aspx

Here's an SO thread does a good job of explanining what needs to be done. The example there might not have the same code as yours, but it provides a good reference point. Unfortunately, I do not see enough of your code in your screenshot:

https://stackoverflow.com/a/17918729/2006048

Community
  • 1
  • 1
B.K.
  • 9,982
  • 10
  • 73
  • 105