|
General Issues (back)
Active X
Can I use Active X and OLE from LabVIEW?
<Chris Hecker Chris.HeckerATCAS.honeywell.com>
(Timeless)
LabVIEW from version 5.x allows the use of Active X. DDE was supported in version 4 onwards. Version 5.1 includes Active X events.
The resource "Understanding ActiveX and OLE " by David Chappell is useful as a starting point. It's written at a high level with little or no code. You do need to gain an understanding of COM by reading the first few chapters before jumping to ActiveX containers.
If you decide to go with ActiveX as opposed to OLE, then the VI usage is limited to the invoke node, property node, and to the G data node. Out of these, the property node is the work horse. Connecting the ActiveX refnum to the refnum input of the property (or invoke) node allows you to specify which property (or method) you want to manipulate. Depending on the property used, you may find that the output from the node is another refnum that serves as input to another property node which then exposes a set of lower level properties that you can use.
If you use OLE, things work in a similar manner, but instead of embedding a control in your program, you're (essentially) creating a script that uses a different application. The application is referenced by using the open automation node. Specify the application by using the Select ActiveX Class offered by the Open Automation VI. The automation open refnums must be closed when finished with them by using the Close Automation VI. As for refnums created by cascading to lower level properties, it is adviseable to close them, but it may not be necessary (unconfirmed).
As for help on specific controls, you will have to rely on the help provided with the controls. COM specifies an interfacing method; there's no (easy) way LabVIEW can know about the properties and methods provided by the controls.
The capabilities offered by including COM in LabVIEW add to the flexibility of the language but, like CINs (Code Interface Nodes), exposes the developer to a lot of the lower level programming issues that were eliminated by LabVIEW. There's been some interesting discussion on the Info-LabVIEW list server concerning brittleness of LabVIEW applications due to different versions of applications, particularly MSOffice. Also, be aware that LabVIEW ActiveX containers do not support events before Version 5.1. So, if you want to respond to a double click on the leaf of a TreeView control, you won't be able to use the double click or hit test methods unless you upgrade your version.
(back)
How do I write data to an Excel spreadsheet?
<Paul Sullivan PaulATSULLutions.com, Alex Le Dain alexATicon-tech.com.au>
(Sep 2000)
Firstly, do you really want to? Certainly Excel and LabVIEW have supported direct communication, whether by OLE, DDE, Active X, or Apple events (for those of us on the minority platform), for many years. (I used direct communication between LabVIEW 3.0 and Excel 4.0). The problem is that Microsoft changes the protocols with every upgrade to Excel. All your carefully crafted code breaks and needs to be redone. Consider the possibility of communicating instead through a tab-delimited text file. That will work with any version of Excel and a large number of other programs as well. LabVIEW supports tab-delimited text files (and other delimiters) with File I/O >> Read From Spreadsheet File, File I/O >> Write To Spreadsheet File, and String >> Spreadsheet String to Array.
Other issues can be incompatible versions between the development system and the target system and does the target machine even have Excel on it? When developing for a general audience, stay with the common denominator.
And what if I still want to write to Excel? Well there are essentially two options. One is to buy a commercial product such as XL-VIEW (see Other Links and Resources) or the Report Generation toolkit (http://sine.ni.com/apps/we/nioc.vp?cid=5769&lang=US). The other is to experiment with Automation. To summarise this process you need to open an automation connection to Excel, and use invoke and property nodes to open a workbook, and then a worksheet, and then you are ready to write to a cell. The Developer Zone on the NI web site (http://zone.ni.com) has several examples on accessing Excel. Furthermore there are ready made snippets in the LabVIEW examples directory (examples\comm\ole-excel8.llb).
(back)
Can I control Word from LabVIEW?
<Alex Le Dain alexATicon-tech.com.au>
(Feb 2003)
Yes you can. The issues on controlling Word are the same as those for controlling Excel. If you have the time you can develop your own code to do this, check out the examples at the Developer Zone (http://zone.ni.com), or perhaps purchase the ready to run WordVIEW toolkit (see Other Links and Resources). Furthermore NI has released the Report Generation toolkit that gives access to report generation using the Windows Office suite (http://sine.ni.com/apps/we/nioc.vp?cid=5769&lang=US).
(back)
How do I set the icons of a tree view control?
<David A. Moore David_A_MooreATMooreGoodIdeas.com>
(Jan 2001)
First create two ActiveX containers on the front panel. Place the TreeView in one, put an ImageList in the other. Second, right click on the ImageList and bring up the editing dialog by selecting either Property Browser or ImageList|Properties (I suggest the latter). Thirdly, use the editing dialog to paste in the images you want and set any other properties. Fourthly on the block diagram set the ImageList property of the TreeView to be the ImageList. Lastly, select the images by name or number for each Tree node.
(back)
|