LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to close an already opened Excel spreadsheet?

I have a spreasheet that is created as a template and opened to write data.
The template remains opened.
I want to close the template because I need to delete the file to create a new template.
How do I close an opened Excel Spreadsheet, using LV?
0 Kudos
Message 1 of 12
(7,844 Views)
 
 
Try using Invoke Node and Close application .
 
 
Regards
 
 
CLAD
Using Labview 5.1,6.1,7.1.8.0
Message 2 of 12
(7,834 Views)

More details:

The vi which creates the Excel spreadsheet leaves it (and Excel) open after it completes.  When you run the vi again, but forgot to close Excel or the spreadsheet, it generates an error when trying to delete it, because the file is in use. I thought of putting a popup message if an error is detected to close the spreadsheet and try again.

Is there a way to confirm that a file or application (Excel) is open and to close it?

 

0 Kudos
Message 3 of 12
(7,819 Views)

hi,

 

If you are using a loop to run your program..You can put this code after the while loop so that every time after the code completes it closes the Excel and the worksheet for sure.

 

Hope it helps. let me know if you need an example for doing it.

 

Regards

CLAD
Using Labview 5.1,6.1,7.1.8.0
0 Kudos
Message 4 of 12
(7,816 Views)
can you attach your Vi to it so that i can understand what you are trying to do...
regards
CLAD
Using Labview 5.1,6.1,7.1.8.0
0 Kudos
Message 5 of 12
(7,816 Views)

No can do.

Let's keep it simple: Is there a way to confirm that an application (Excel) or file is open?

0 Kudos
Message 6 of 12
(7,808 Views)

Well I dont know if you can find out if a file is already open or not.

But you can definitely close one which is open.

Did you tried doing what i told you in Reply 4 . Put the code in the end of the program

 

All you need is to wire a reference from your excel workbook . i have attached a small program getting the Print preview of an excel document. It is closing excel afterwards.

 

You can try inserting your own code inro it.

Also in the initial filename for book , select path of any excel sheet on your computer before starting.

 

Let me know if you face any difficulty.

Can you attach a print screen of your code. It can help me understand your problem better.

 

Regards

CLAD
Using Labview 5.1,6.1,7.1.8.0
Message 7 of 12
(7,794 Views)
Simply wire an Invoke Node and set property to "Quit".
 
Message 8 of 12
(7,770 Views)

You could use the windows API.  There are some VI's that you can download and unzip to your user folder that will do some windows API functions.  One of the VI's will get a list of running apps from windows task manager (Get Task List.vi).  You can then close the app that you want.

http://zone.ni.com/devzone/cda/epd/p/id/4935

Message 9 of 12
(7,758 Views)
Using ActiveX, as others have suggested, you can close Excel.  The Excel application, if open, will give a prompt to save any un-saved files however.
 

Message Edited by paulmw on 10-20-2006 10:03 AM

Message 10 of 12
(7,752 Views)