0

Thank you for taking the time to read my question.

I am developing a small application to do the following:

  1. Read each .xlsm Report in a specific directory
  2. Grab specific field based on different Report types
  3. Store the fields in a custom class object
  4. Store the custom class object in a List<>
  5. After reading all the .xlsm Reports, create a new Tally Report from a template
  6. Output the data from each custom class object in the List<> to the new Tally Report

This is working great. But I added a new feature so that if an exception error occurred, I could prompt the user using a custom message box to either Edit or Remove the document or Ignore the exception and continue getting the remaining data.

When the user selects "Edit", it calls a class file that dynamically generates a new Form, add a DSO Framer Control to the new Form, and then opens a specific file from the parameter passed in.

The first time I receive my message box and select "Edit", it will open the new form correctly and display the .xlsm report for me to edit. Once I click Close, it saves the changes and continues on processing. If I receive my message box a second time and select "Edit" (whether for the same .xlsm file or not) I received an Exception:

"Exception has been thrown by the target of an invocation."

I thought it may have been because the document had already been open using "Microsoft.Office.Interop.Excel", but the first .xlsm file will open even though it had been opened using "Microsoft.Office.Interop.Excel". I did notice that When using "Microsoft.Office.Interop.Excel" I still had an Excel process running in Task Manager after calling the Excel.Application.Quit() function and using Marshal.ReleaseComObject on the ExcelApp object.

If I complete close the application and reopen it, I can "Edit" again the first document that prompts my message box.

All I need is to be able to do when I select the "Edit" option is to pause the running code, display the file for the user to edit, and once they're done editing continue running the code again.

Please advise.

I just tried posting the code in here too and it said I used too many lines. Whats the best way to share all of my code?

  • DsoFramer has been discontinued a long time ago. It is not compatible with recent Office versions, 2007 was already very troublesome. You need to stop using it. More in [this question](http://stackoverflow.com/questions/1439168/ms-kb311765-and-dsoframer-are-missing-from-ms-site). – Hans Passant Dec 05 '13 at 23:54
  • I'm aware it has been discontinued and has many issues. I am able to make it work in testing it in a project using just the DSO Framer. I don't mind giving up on it. It just would be nice if there was to tweak it to make it work. It would make my next project SO much easier. Do you have any other references to use instead of DSO Framer? – Paul - SGS PfINDE Dec 06 '13 at 01:59

0 Answers0