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: 

CLOSE EXCEL

Hi all :

Please see attach file :

 

How can I save and close excel automatically

 

Thanks

 

0 Kudos
Message 1 of 6
(4,206 Views)
Hi elyan,
 
This vi you sent is openning a worksheet.
 
You can save it creating a method in the output of the Open New Worksheet.vi. Choose the SaveAs method. Wire a string containing your excel file path in the Filename input.
 
You can close the excel creating a method with the reference in the output of the Open Excel and Make it Visible.vi and choosing the Quit method.
 
If you didn't understand that consider the possibility of using the Report Generation Toolkit for Microsoft Office because it's pretty easier or search for examples like Write Table To XL.vi, where you will see the save and close operation.
 
FSouza
0 Kudos
Message 2 of 6
(4,184 Views)
0 Kudos
Message 3 of 6
(4,133 Views)

Hi

 

I'm having this very problem.I'm trying to open write then save and close and I'm having trouble with the latter. Right now when I run by VI twice, I get a message saying the file is already open and whether I want to open it again, meaning that it wasn't closed in the first place. Is there a Save option rather than a SaveAs option

 

I tried the VI uploaded by aeastet but I couldn't get it to work.

 

Thanks

0 Kudos
Message 4 of 6
(3,087 Views)

Hi

 

So for my application, I want to write/modify an existing excel file (a worksheet) without ever having it visible to the user and without any pop-ups (hence why I can't use the SaveAs function as when the file is present it gives a pop-up askng to replace the file). I'm thinking it may be possible to read, store the information, delete the file, and then create and save a new file with the same name but I think that's an overkill just to get around the lack of a Save method node. 

 

Thanks

0 Kudos
Message 5 of 6
(3,081 Views)

You are handling the references in a way i get stomacheache. ActiveX and .NET references should be opened one after another and closed in opposite order in the end of the application/use case.

 

Regarding your question:

I suggest you to modify the sheet/cell, but the call Save for the Workbook and then you can close (unload) the Workbook.

 

You will not find a close method for worksheets or cells.

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 6
(3,076 Views)