Jump to content
Steve Morris

Is it possible to run Excel in the background?

Recommended Posts

I have an application that uses the report generation functions to write test data into an Excel file. I've set it up to open Excel minimized, but I'd like to run Excel in the background or 'hidden' so that the operator can't accidently close the file during the test run.  Does anyone know how to do this?

Share this post


Link to post
Share on other sites

Check the Excel .NET API reference from Microsoft. The application object has an option to start hidden.

  • Like 1

Share this post


Link to post
Share on other sites

Gribo,

Thanks for the reply, unfortunately I can't find an Excel .NET API from Microsoft.  If I drop a .NET constructor node on my block diagram and go to select an assembly, the only Excel one I can find is Microsoft.Office.Interop.Excel and it's application object has no public items.  I've tried searching the web for an Excel .NET API and can't find anything from Microsoft other than what I already have.

 

I must be looking in the wrong places, can you point me in the right direction?

Steve

Share this post


Link to post
Share on other sites

The RGT uses ActiveX, not .NET.

 

There's a thread with Excel examples here, and I assume at least some of the newer ones are probably with the .NET API - http://forums.ni.com/t5/BreakPoint/Excel-Board/m-p/379682#M2391

 

 

Looking at your OP, I see that you're using the RGT. It has a VI which returns the Excel ActiveX references. You should be able to use that to get the Application reference and set it to hidden (I think there's a Visible property, but I didn't really play much with it, so I don't remember for sure that I even did this).

  • Like 1

Share this post


Link to post
Share on other sites

Gribo, martin_g and Yair,

Thanks for the help.  Indeed in the guts of the RGT's New Report.vi is a Visible property that allows you to run 'hidden' if you set it to False.  One good and bad thing about it is that it just works for the file that you open with the RGT.  Good because you don't have to reset it to True to use Excel once you are finished with it in LabVIEW.  Bad because if you open any other Excel file, outside of LV, while you are using the 'hidden' one in LV, the hidden one is no longer hidden.

 

I don't know if this will be enough security for this application (if an operator were to stumble through to the active Excel file and close it we could lose a couple days of test data), but it is good to know.

 

Thanks again.

Share this post


Link to post
Share on other sites

I don't know if this will be enough security for this application (if an operator were to stumble through to the active Excel file and close it we could lose a couple days of test data), but it is good to know.

 

I would strongly suggest NOT using Excel to save your data. Pick a method to save your data (examples include a simple binary file, TDMS, CSV files, databases, etc.) and if you want to see the data in Excel, export a copy of the data to a format that Excel understands. That way, your data will not be dependent on what the user does.
  • Like 2

Share this post


Link to post
Share on other sites

Using the ActiveX API can yield some odd behaviour if you then "manually" interact with Excel, launching another instance for example. 

 

If you have long running tests then I suggest that streaming to Excel is not ideal. Might be better to write to a database or TDMS file and then arrange for the data to be exported in an appropriate manner. Remember there are size limitations to the number of rows you can have depending on your Excel version, again worth consideration.

 

All that being said, if I can help with the Excel API then just ask

 

Chris

Share this post


Link to post
Share on other sites

The end user requires Excel in this case.  I think what I'll end up doing is saving everything in csv format while the test is underway and write it all into the Excel template when the test completes.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.