LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

detecting excel opened

Hello,
Is there a way to detect if excel is already opened? Opened in background?
Indeed, It appears in my program that excel is not correctly closed and stay opened in background (excel.exe task). I want to detect if it 's opened or not (in background or not)
Thank you
labview 7.0
0 Kudos
Message 1 of 9
(3,678 Views)
Using activeX references, you can call the method "exit" which will quit the excel application, this will close the application.  I think that if your program opens excel through automation then quits, this will not close excel and you might have to kill it using the task manager (I havent had to do this) but you can programatically exit excel through an activeX method call.  Using the properities, you can see the state excel, but it will always appear to be opened since the activeX reference will need it opened to check the properities of the application.  You can check to see if a particular workbook is opened however.  See the attached vi (sorry this is for Office 2002 so it might not work for you), but it does close excel for you.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 9
(3,668 Views)
Oops, I pressed submit post instead of attach, here is the attachment, I haven't had my caffeine fix yet.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 9
(3,665 Views)
I also would like to know if excel is open, but closing Excel by default is not the solution I want to use. I`d like to keep Excel in the state just the way it was before I used it. So if it was closed Excel should be closed again,  if someone has been working in Excel this work shouldn`t be affected.

If anybody knows a way to detect if Excel is open or not please let me know.

thanks,
Flo


P.S.
I`m using
Labview  7.1 and controlling Excel via ActiveX
http://morphin.org
0 Kudos
Message 4 of 9
(3,547 Views)
Try to get a list of the processes running on the computer from task manager. There is a labview example that simulates task manager.
Message 5 of 9
(3,530 Views)
Thanks for the tip. I found the example it can be found in the labview examples:
Examples -> Communicating with External Applications -> .NET -> SimpleTaskmonitor.vi

I think this will work out just fine for me.

bye,
Flo
http://morphin.org
0 Kudos
Message 6 of 9
(3,510 Views)

Hello Paul

 

I have checked the example you uploaded, and I have a queestion:

 

Have you checked the task manager when the code for exit the application (quit invoke node)?

 

I have a code that Open a excel worksheet, read a value, and close it. I close all the references opened, and execute the quit invoke node for the application. But when it finishes its executions, excel.exe process is still opened in task manager of windows (but not in the task bar).

 

What I'm missing? How can I close excel process completely?

 

Thanks in advance.

 

Best regards

Ing. Electrónico - Director Proyectos - NECSYS S.A.S.
0 Kudos
Message 7 of 9
(2,967 Views)

@javier.reyes wrote:

What I'm missing? How can I close excel process completely?

 

I suspect your problem is the Excel._Worksheet that you are passing to Variant to Data.

0 Kudos
Message 8 of 9
(2,950 Views)

not quite what you guys are asking for, but if you have the Office report generation toolkit add-on, you might find some useful NI created VI's to do various Excel tasks using activeX.  If you open up "NI_Excel.lvclass:new report subVI.vi" for example, you can see some ways to open Excel, get/set window states etc. 

QFang
-------------
CLD LabVIEW 7.1 to 2016
0 Kudos
Message 9 of 9
(2,945 Views)