[iis-7] How to fix 'Microsoft Excel cannot open or save any more documents'

I am running C# ASP.NET 4.5 web application on Windows 7 64-bit using IIS 7.5. The application pool it uses has the name 'ASP.NET v4.0' and its identity is ApplicationPoolIdentity. The application uses MS Office Interop (Microsoft Excel 14.0 Object Library).

At line wBook = wBooks.Add(Missing.Value);, it throws the following error:

Microsoft Excel cannot open or save any more documents because there is not enough available memory or disk space.

u2022 To make more memory available, close workbooks or programs you no longer need.

u2022 To free disk space, delete files you no longer need from the disk you are saving to.: at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)

1) I gave the account IIS apppool\ASP.NET v4.0 full control on MS Excel Application in DCOM Config.

2) I gave IIS apppool\ASP.NET v4.0 full control on 'C:\Windows\SysWOW64\config\systemprofile' and created a Desktop folder in it.

3) I need to continue using Interop though it's not recommended.

4) The application works fine on Windows Server 2003/Windows XP 32-bit.

5) MS Office 2010 (64-bit, trial version) is installed on the machine.

6) I would prefer not to change the app. pool identity from ApplicationPoolIdentity to Network Service etc.. ApplicationPoolIdentity is the new type of Identity in IIS 7 and it's recommended.

It works fine if I select 'Interactive User' (I have logged in as an admin) in DCOM Config, but it causes other problems. I need to use 'Launching User' which is ASP.NET v4.0. So it looks like it's a permission issue.

Please help. Thank you.

The answer is


Test like this.Sometimes, permission problem.

cmd => dcomcnfg

Click

Component services >Computes >My Computer>Dcom config> and select micro soft Excel Application

Right Click on microsoft Excel Application

Properties>Give Asp.net Permissions

Select Identity table >Select interactive user >select ok


I too encountered the same scenario and found out two solutions after googling for several times. Hope this helps.

Way 01:

Before trying to open the file in Excel, find it in Windows' File Explorer. Right-click the file and select Properties. At the bottom of the General tab, click the Unblock button. Once you unblock a file, Windows should remember and Excel should not ask you again. This option is available for some file types, but not others. If you don't have an Unblock button, use Way 2.

Way 02:

This option is better if you usually store your downloaded Excel files in one folder. In Excel, click File » Options » Trust Center » Trust Center Settings » Trusted Locations. Click Add new location. Browse to the folder where you store your Excel files, select Subfolders of this location are also trusted, and click OK.


I had this same issue, there was no issue regarding memory in my server machine, Finally i was able to fix it by following steps

  1. In your application hosting server, go to its "Component Services"
  2. enter image description here

3.Find "Microsoft Excel Application" in right side.

4.Open its properties by right click

5.Under Identity tab select the option interactive user and click Ok button.

Check once again. Hope it helps

NOTE: But now you may end up with another COM error "Retrieving the COM class factory for component...". In that case Just set the Identity to this User and enter the username and password of a user who has sufficient rights. In my case I entered a user of power user group.


Right click on the file with file explorer, choose Properties, then General tab and click on the Unblock button. This error message is very misleading.


After giving necessary permissions in DCOM configurations I also needed to change the identity of my application in the IIS to a custom account


Go to this key on Registry Editor (Run | Regedit) HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

change key Cache to something like C:\Windows\Temp

My similar problem was solved like this.

Regards,

Ripley


If none of the above worked, try these as well:

  • In Component services >Computes >My Computer>Dcom config>Microsoft Excel Application>Properties, go to security tab, click on customize on all three sections and add the user that want to run the application, and give full permissions to the user.

  • Go to C:\Windows\Temp make sure it exists and it doesn't prompt you for entering.


Examples related to iis-7

Accessing a local website from another computer inside the local network in IIS 7 500.21 Bad module "ManagedPipelineHandler" in its module list HTTP Error 503. The service is unavailable. App pool stops on accessing website IIS - 401.3 - Unauthorized 500.19 - Internal Server Error - The requested page cannot be accessed because the related configuration data for the page is invalid ASP.NET Web API application gives 404 when deployed at IIS 7 WebApi's {"message":"an error has occurred"} on IIS7, not in IIS Express enabling cross-origin resource sharing on IIS7 How to fix 'Microsoft Excel cannot open or save any more documents' IIS 7, HttpHandler and HTTP Error 500.21

Examples related to asp.net-4.0

The type is defined in an assembly that is not referenced, how to find the cause? ASP.net Getting the error "Access to the path is denied." while trying to upload files to my Windows Server 2008 R2 Web server Check if Cookie Exists How to fix 'Microsoft Excel cannot open or save any more documents' Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0 How to fix: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list ValidateRequest="false" doesn't work in Asp.Net 4

Examples related to office-interop

How to properly set Column Width upon creating Excel file? (Column properties) Importing Excel into a DataTable Quickly How to fix 'Microsoft Excel cannot open or save any more documents' What reference do I need to use Microsoft.Office.Interop.Excel in .NET? How to read an excel file in C# without using Microsoft.Office.Interop.Excel libraries Reading Datetime value From Excel sheet How to make correct date format when writing data to Excel Create Excel files from C# without office Exporting the values in List to excel C# - How to add an Excel Worksheet programmatically - Office XP / 2003

Examples related to windows-7-x64

"The following SDK components were not installed: sys-img-x86-addon-google_apis-google-22 and addon-google_apis-google-22" The service cannot accept control messages at this time Creating self signed certificate for domain and subdomains - NET::ERR_CERT_COMMON_NAME_INVALID ImportError: No module named enum Git credential helper - update password Can't connect to MySQL server on '127.0.0.1' (10061) (2003) Register .NET Framework 4.5 in IIS 7.5 Windows 7 - Add Path How do I start Mongo DB from Windows? How to completely remove node.js from Windows

Examples related to excel-interop

Closing Excel Application Process in C# after Data Access Optimal way to Read an Excel file (.xls/.xlsx) How to fix 'Microsoft Excel cannot open or save any more documents' How do I import from Excel to a DataSet using Microsoft.Office.Interop.Excel? HRESULT: 0x800A03EC on Worksheet.range How to count the number of rows in excel with data? System.Runtime.InteropServices.COMException (0x800A03EC) How do I auto size columns through the Excel interop objects? Exporting the values in List to excel