There are plenty examples on the web and shipped with LabVIEW on how to use Excel. But once you start developing more or less complicated applications you start dealing with sharing Excel instances with other Users, programs and within the application itself.
Below I would like to share my solution to Excel sharing in multi-user environment.
In future it would be really nice if: native LabVIEW Automation Open
allows us to request instance by name or ID, not just new or unknown instance.
Built-in Excel features used:
- IgnoreRemoteRequests (disables DDE interface, COM call's still need to be tracked or kept in mind) - to reserve given Excel instance for LabVIEW only
- DisplayAlerts - to leave error checking to LabVIEW only
- UserName - for identification in LabVIEW environment
- AutoRecover -> Enable - for house cleaning purposes
Concept:
A storage VI with 7 modes:
Mode/Command | Description | Usage |
---|
List All | Lists all active (obtained by this vi) Excel instances | normal(default) |
Open New Instance | Opens new instance of Excel Application | normal |
Get Instance by Name | Gets active LabVIEW's Excel App. RefNum | normal |
Close Instance by Name | Closes active instance by Name | normal |
Close instance by RefNum | Closes active instance by RefNum | normal |
Kill All | Kill's all active Excel instances (global process kill command) | house cleaning |
Close All | Closes all active LabVIEW"s Excel instances | normal |

Simple Example provided.
04/26/2011 Update:
- minor facelift
- "List All" command added
04/27/2011 Update:
- On Exit Excel must be returned to DDE listen state, otherwise it would ignore requests from OS to open documents (Directly still would work)
- Check on instance name collision
- Additional error checking
05/02/2011 Update:
Bug found in Close by RefNum.