Hello, with following code I created an instance of Excel out of Navision: IF ISCLEAR(xlApp) THEN CREATE(xlApp); xlBook := xlApp.Workbooks.Add(-4167); xlSheet := xlApp.ActiveSheet; xlApp.Visible := TRUE; CurrForm.Close; Excel opens successfully but if I close Excel manually I get an access violation from Excel. Does anybody know why? Do I have to do something more inside Navision before closing the Navision form? Thanks for any help!
I’m not sure, But I think you have te release the document (closing instance) within Navision.
You must close the Excel thread via the automation controller, not manually.
Hi
quote:
Originally posted by CMDunbar
You must close the Excel thread via the automation controller, not manually.
Sorry. I can’t agree. I work a lot with Excel automation. In most of the cases the Excel files are still open (after running the automation) for user action. IMHO the access error should have another reason. bye André
I think xlBook.close will do the trick.
Hi
quote:
Originally posted by dr.burns
… Do I have to do something more inside Navision before closing the Navision form? …
In a lot of tests and with the help of this forum I found out that it would always be a good idea to run automation code with a codeunit instead a form or a report. Otherwise Navision and Excel cause some strange errors. Try your piece of code in a codeunit. bye Andre
Hi I had the same problem when creating an Excelsheet from a report. I used the standard table 370 Excel Buffer with its functions. I made this change to function GiveUserControl() GiveUserControl() XlApplication.Visible(TRUE); XlApplication.UserControl(TRUE); CLEAR(XlApplication); // New Code CLEAR(XlWorkBook); CLEAR(XlWorkSheet); // End New Code
It seems to work… Bye Magnus