+ Reply to Thread
Results 1 to 2 of 2

SaveAs method throws exception

  1. #1
    Registered User
    Join Date
    08-04-2015
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    2

    SaveAs method throws exception

    I'm working on a .NET program to interface with Excel. The code looks like this:

    Please Login or Register  to view this content.
    As you can see, it is simply used to convert an .xlsx file to a .xls file (Excel 97-2003 format).

    When I run this code it throws exception:

    System.Runtime.InteropServices.COMException was unhandled
    HResult=-2146827284
    Message=Exception from HRESULT: 0x800A03EC
    Source=testcs
    ErrorCode=-2146827284
    StackTrace:
    at Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
    at testcs.Program.ConvertToXls(String xlsxFn, String xlsFn) in c:\Users\Redirection\brittg2\Documents\Visual Studio 2012\Projects\testcs\Program.cs:line 104
    at testcs.Program.Main(String[] args) in c:\Users\Redirection\brittg2\Documents\Visual Studio 2012\Projects\testcs\Program.cs:line 95
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:
    While troubleshooting, I ran the steps in my code interactively in Excel. They worked as expected and the converted file appeared in the destination directory.

    I should mention that the destination directory is on a different computer. The second argument to the function is given as a UNC path.

    Any ideas what's going on here?

  2. #2
    Registered User
    Join Date
    08-04-2015
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    2

    Re: SaveAs method throws exception

    Found the answer:

    xlExcel9795 is deprecated, though still in the enumeration. If you use it, an exception is thrown.

    See: https://social.msdn.microsoft.com/Fo...forum=exceldev

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel Automation: Setting WindowState throws exception in Excel2013
    By Anandh123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2013, 02:02 AM
  2. SaveAs Method not working
    By excelforum123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2013, 02:49 AM
  3. Copy a worksheet throws "Exception from HRESULT: 0x800A03EC."
    By i3tech in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2006, 08:40 AM
  4. get_Range function throws an exception
    By Mikil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2006, 10:15 AM
  5. [SOLVED] Excel SaveAs() method
    By Sandrina in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2006, 10:55 AM
  6. Excel throws exception if cell being edited
    By Pixeled in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2005, 03:05 PM
  7. [SOLVED] A little help with SaveAs Method please
    By Stitch45 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2005, 09:07 PM
  8. Difficulties with SaveAs method
    By aiyou in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2005, 10:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1