Click here to Skip to main content
15,868,002 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi there,

I have written a COM-Exposed dll using Framwork 2.0 which implements MS Excel. The dll saves the provided data (usually a datasource that populates a grid) splinted in as many xls files as needed with x rows per sheet and y sheets per file (both user-provided params) using a given name + datetime (sufix) and storing the files in the provided path (param as well).

It does work like a charm when invoked from a .Net or VB6 app in my development machine, but when I try to deploy it so that it can be used by apps (.Net or VB6) residing in a network machine it gives me all sort of headaches.

After dealing with a number of things including having to give Local Intranet :) & Internet:confused: zones full trust using the Framework's configuration wiz, registering dependat dlls, etc, I got to what I think is the "last" issue which offers this error message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, blah, blah, blah..." and it would simply not work passed this.

Well, once I got out of ideas I changed the save-path from "C:\" + userprovidedparam to Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + userprovidedparam and now I still get the nasty message but then, the system asks me if I want to save the changes to my xls file(s). When I select the "retry" button I get the Save as dialogue and are able to save my file(s); this does behave differently in XP and Vista, but bottom line is: I get to save the files.

Question is: How do I get rid of both the error message and the Save as prompt?

Thank you so much for your time and interest in my "little" problem.

Alex.

PD. Yes, I have searched the web for clues, but I found myself clueless.
Posted
Updated 6-Oct-10 15:39pm
v3

1 solution

If you use a version of Visual Studio later than 2002, than the user base may need to install XP SP3 or a later OS, and .NET framework.

Note that if you have any memory errors at all, Excel is unstable.
 
Share this answer
 
Comments
alexvw 22-Oct-10 19:30pm    
Hello Ted2102, thank you for your insight. I am afraid that all machines have both the SP3 and .Net frameworks properly installed. I have been working with it some and I still have issues when attempting to save all files to the user's C: drive, and a few hurdles that seem to be related to .dll reference paths.
T2102 22-Oct-10 22:45pm    
Another issue that may be unrelated is that when you launch Excel programatically, you need to load all of your add-ins programatically. They will be checked by excel, but may not be available.

Your error message sounds like a permission issue; in SQL Server you would need to run sp_configure to allow access to various paths.

You can get rid of the save as prompt using the Workbook_Before_Save event or something similar to that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900