From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if an Excel Application is open and if yes to close it before running a labview VI

Solved!
Go to solution

Dear all,

 

I have a VI which takes measurements and store them in an Excel worksheet after some numerical manipulations. I have been very careful to close anything in the correct order before making an "Application Quit" at the end of the Labview VI

 

The VI is running well and as many times as we want as long as no Excel application has been left open (opened by hand to check data for example) before running the labview VI.

 

So presently I have to be careful that no Excel application is open before I start the VI.

 

Can someone tell me how my Labview VI can detect (at the starting) if an Excel application is already open and then close it in case yes ?

 

Thank you

 

Youki

 

 

0 Kudos
Message 1 of 8
(7,513 Views)
Solution
Accepted by topic author Youki

Here you go,

 

cheers

 

Excel Check.png

Excel close.png

Message 2 of 8
(7,505 Views)
Addendum: Alternatively, to check to see if Excel is running you can use System Exec to issue the tasklist command and then search the output for "excel.exe".
Message 3 of 8
(7,482 Views)

hello,

 

What are the names of the two VIs which are shown in the picture after ActiveWorkbook ?

I tried to find these in variant pallette, but was not able to.

 

Please let me know the VI names.

Thank you

0 Kudos
Message 4 of 8
(6,482 Views)

They are Flatten to String and Unflatten From String. In the Numeric-> Data Maipulation.

0 Kudos
Message 5 of 8
(6,471 Views)

Sorry, I know this is an old post, but I have had a similar problem for some time and never found this post.

 

Can you tell me if this will also close a worksheet, but leave other worksheets open?  I have a VI that has up to three worksheets open in Excel at a time, but needs to detect if the worksheet is already open.  If it is not, a new one will be made from the template.

 

Thanks.




metzler CLAD
0 Kudos
Message 6 of 8
(5,728 Views)

Hi,

I tried the code that you suggested on LabVIEW 2015. It returns only false in all scenarios! any alternate methods except SystemExec method?

0 Kudos
Message 7 of 8
(4,423 Views)

Instead of Checking for the Active Work book, try to find the list/Count of Workbooks and Extract the required workbook name and use workbook close option via Automation refnum property.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 8 of 8
(4,414 Views)