1

I have a problem with the integration of MS Excel into my java application. I use Jacob to talk to Excel via the COM API, which generally works fine. An XLS file can be opened from the application, and changes are properly stored.

But then I just noticed my code becomes buggy when Excel is already opened and at least one workbook was changed in memory but not already saved. A simple statement like this one fails with an exception:

excel.getProperty("Workbooks");

I do very little with the workbooks collection: just adding a new workbook or counting its size. This really should work somehow.

Do I miss something?

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
avh
  • 178
  • 2
  • 11
  • I get a ComFailException: Can't map name to dispid: Workbooks – avh Nov 02 '10 at 16:05
  • In fact it's not a matter of unsaved changes but of a cell that is currently opened (for editing). If I change a cell's value and leave the cursor right there, it fails. However, if I move the cursor to another cell or just press return, it works again. So it seems all I need is a command to close open cells or something like that. – avh Nov 02 '10 at 19:43
  • I learned another thing today. As long as a cell is being edited in excel, scripting is prevented. So there is no direct way to abort the editing, as there is no way to open another file, etc. BUT it should be possible to send the application an ESC key somehow. This did not work using the SendKeys method on the excel application object itself. Did someone got this working somehow? – avh Nov 03 '10 at 16:13
  • I tried to reproduce this using a little VB script, but was not successfull. It seams to be a java/jacob-specific problem. I keep working on it. – avh Dec 09 '10 at 09:15

0 Answers0