Note that there are some explanatory texts on larger screens.

plurals
  1. POEmbarcadero C++ builder Excel Automation C++ does not quit
    primarykey
    data
    text
    <p>I am trying to Automate Excel so that it generates a report on a server and then emails this to a user when requested. The problem I have is that once I have created an excel document and written the data into it, the program does not not quit even after issuing the pXL->Quit(); command. This is what my instructions for "closing" excel:</p> <pre><code>pXL-&gt;Workbooks-&gt;Close(LCID(LOCALE_USER_DEFAULT)); pXLWSs.Reset(); //Releases Worksheets pXLWS.Reset();//Releases Workbooks pXL-&gt;Quit();// "Quits" Excel ---&gt; This does not quit excel pXL.Reset();//Release Excel application? CoUninitialize();//Uninitialise COMS </code></pre> <p>I have read quite a few articles and blog about this particular issue and it seems that this is because I am not freeing all the COMS associated with Excel. So I tried uninitialising COMS a few times. I issued the</p> <pre><code>CoUninitialize(); </code></pre> <p>4 times and this worked! But to my disappointment, it does not work all the time. </p> <p>Does anyone know how to gracefully close Excel?</p> <p>I know Microsoft does not support server side Excel Automation but I was hoping to find a work around. I am also aware that you can simply</p> <pre><code>WinExec("taskkill /F /IM \"excel.exe\"",0); </code></pre> <p>which kills Excel altogether but I am worried about the future of the app when it will be generating quite a number of excel applications in which case I would have to kill Excel individually and it all just gets messy from there....</p> <p>Any help would be much appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload