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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ExcelRpt_ApplicationNew hidden?

Solved!
Go to solution

This function has a parameter called "visible".  Pretty self explanatory:

 

Specify a nonzero value or VTRUE or select Yes in the function panel to create a visible application instance.

Specify 0 or VFALSE or select No in the function panel if you do not want the instance to be visible.

 

When I call it with a 0, however, other functions like ExcelRpt_WriteData and ExcelRpt_SetCellValue aren't working.  They aren't throwing any errors, but my target workbook isn't getting any data.

 

If I simply call the ExcelRpt_ApplicationNew in visible mode, then the data writes correctly.  Is this option broken?

0 Kudos
Message 1 of 6
(3,582 Views)

Some more observations...

 

From this helpful thread, I see that I did indeed have lots of ghost EXCEL.EXE files in the background, mostly from stopping my application in debugger and then not allowing it to quit normally so that handles were discarded.

 

I force quitted them all and then restart my app.  Here's what I'm seeing.:

  1. ExcelRpt_ApplicationNew always spawns 2 EXCEL.EXEs, not 1.  Why?
  2. Quitting properly with CA_DiscardObjHandle and ExcelRpt_ApplicationQuit never closes any of the EXCEL.EXEs.  Why?

 

 

0 Kudos
Message 2 of 6
(3,574 Views)

Ok, I do see where my first post went wrong.  You have to explicitly save the file before closing it with ExcelRpt_WorkbookSave.

 

I'm still not clear why I get two instances of Excel open and they never close either.

0 Kudos
Message 3 of 6
(3,571 Views)
Solution
Accepted by ElectroLund

Hi ElectroLund,

What version of LabWindows/CVI are you using? I have tried this in both 2013 SP2 and 2015 and have not been able to recreate the behavior you were seeing using Office 2016. I was able to produce a couple cases where Excel takes a long time to actually close when running it in the background, but I did not see 2 Excel Applications open from a single call of the function in question, and every Excel process instance eventually closed. 

Could you try running the "excelreportdemo.cws" example from the LabWindows/CVI Example Finder? You can find this by going to "Help->Find Examples..." and then navigating to "Communicating with External Applications->ActiveX->Excel" and selecting the example in question. This is the example I was using to test on my system. It sounds like the issue could be strange behavior from Excel's end.

Charlie J.
National Instruments
Message 4 of 6
(3,546 Views)

I'm on CVI 2015.  I found my problem.  It was a rather insidious little issue with the error handler macro I wrote, in which it was actually calling the function twice.  That's resolved now.

 

However, in both the excelreportdemo and my app, the instance of EXCEL.EXE isn't getting closed when ExcelRpt_ApplicationQuit is called.  The worksheet and application visually close.  No tray icon, etc.  But in Task Manager, the Process is still running.

 

As you say, I'll keep an eye on the list and see if it just is taking a long time to go away. 

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

Things have "settled down" and I eventually saw that Process go away.  In fact, with successive runs, I'm now seeing EXCEL.EXE close immediately.  

 

Thanks for your help!

0 Kudos
Message 6 of 6
(3,536 Views)