NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

Failed to proceed Method ExportAsFixedFormat for Excel #268

Closed boon2468 closed 4 years ago

boon2468 commented 4 years ago

Hi, I've a written an Excel conversion app (to PDF, using the ExportAsFixedFormat function) which I triggered from another Windows Service on a regular basis. The MS Office installed is 2013 on Windows Server 2012. The app has been working for 2 years without any problem.

But recently starting around March, I keep hitting the error "Failed to proceed Method on Excel.WorkBook => ExportAsFixedFormat"

I've tried to find anything I can on the web but there is no info at all. Has anybody ever encounter this before?

Thanks in advance. regards, Boon

jozefizso commented 4 years ago

Which version of NetOffice library are you using?

boon2468 commented 4 years ago

I'm previously using 1.7.4.1 and later upgrade to 1.7.4.8 But both saw the same error.

boon2468 commented 4 years ago

After some tryout, we manage to resolve this by changing the DCOMCNFG setting. Here's how we resolve this: Run dcomcnfg Under the [Component Services > Computers > My Computer > DCOM Config] , look for "Microsoft Excel Application" and right-click on it and select [Properties]. Then, under Security tab, change the [Configuration Permission] to "Custom" and give "Full Control" to Users group and All Application Pages. Next, go to Identity tab and change it to [This user]. Assign a local user with admin role. Click [Ok] to save.

Altho we resolve this issue, I'm not sure what triggered this problem in the first place. Perhaps some one has some insights? Thanks.

jozefizso commented 4 years ago

Yes, this is a normal setting which needs to be applied in some scenarios (mostly when you either run under IIS or as Windows Service).

And it depends on many factors, it's either update which changed some settings or it may me some other configuration which was modified at the time.

boon2468 commented 4 years ago

After changing the DCOM setting, although it can resolve the issue with calling from window service, another problem came up. Whenever u open MS Excel, an error "Cannot use object linking and embedding" pop-up! I think most likely, this is caused by the DCOM changes!

boon2468 commented 4 years ago

The "Cannot use object linking and embedding" issue is resolved after changing the DCOM Identity setting to "Interactive User"!

jozefizso commented 4 years ago

This guide for accessing MS Office API from IIS and DCOM configuration applies to NetOffice too: https://www.ryadel.com/en/office-interop-dcom-config-windows-server-iis-word-excel-access-asp-net-c-sharp/

boon2468 commented 4 years ago

Thanks for the info.