LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check that Excel is not closed in CVI?

Solved!
Go to solution

I use Excel Report Instrument to pass data to Excel that I start with ExcelRpt_ApplicationNew. All works fine until I close the Excel manually.

So question is: how can I check from CVI that the Excel application window is not closed?

0 Kudos
Message 1 of 3
(3,284 Views)
Solution
Accepted by topic author ZVS

Hello ZVS,

 

Here is some sample code that you can use to tell in Excel is open. This checks if the process is in Task Manager and returns a negative number if Excel is not open. 

 

 

#include "excel2000.h"
#include <cvirte.h>
static HRESULT status;
static CAObjHandle handle;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1;    /* out of memory */
status = 0;
status = Excel_ActiveApp (NULL, 1, LOCALE_NEUTRAL, 0, &handle); 
CA_DiscardObjHandle (handle);
return 0;
}

 

#include "excel2000.h"

#include <cvirte.h>

static HRESULT status;

static CAObjHandle handle;

int main (int argc, char *argv[])

{

if (InitCVIRTE (0, argv, 0) == 0)

 return -1;    /* out of memory */

status = 0;

status = Excel_ActiveApp (NULL, 1, LOCALE_NEUTRAL, 0, &handle); 

CA_DiscardObjHandle (handle);

return 0;

}

 

You just need to make sure to add the Microsoft Excel Report function panel to your project. You can do this by going to the Instrument menu and selecting Load. It should be located at <National Instruments>\CVI2009\toolslib\activex\excel\excelreport.fp

 

Have a great day!

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,246 Views)

Thank you!

I tried to find a function in Excel Report tool but this function from Excel 9.0 Object Library. So I have searched in a wrong place. Smiley Wink

 

0 Kudos
Message 3 of 3
(3,244 Views)