LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX class not recognized using Excel example

I downloaded example code for writing ASCII table to an Excel file. The VI called Open Excel and Choose Visibility used an Automation Open VI to open an Excel application, and error -2147221 was returned: class not registered in Open Excel and Choose Visibility. What class do I have to register and how do I do it?
0 Kudos
Message 1 of 5
(2,961 Views)
Good afternoon Connie,

Here is a great reference on registering ActiveX controls: http://digital.ni.com/public.nsf/websearch/4F811A9B23F1D46E862566F700615B7A?OpenDocument


If you are just wanting to write information to a file and be able to open it in Excel, I would recommend not using ActiveX and instead use the LabVIEW "Write to Spreadsheet File" VI. This VI will write your data in tab-delimited text format file, which Excel will know how to convert to a spreadsheet when the file is opened.

Hope this helps,

Regards,

Travis M
Applications Engineer
National Instruments
Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 5
(2,951 Views)
Travis, I tried Write to Spreadsheet File, but that VI only takes numeric input, which it converts to text to send to Excel. I need a VI that takes ASCII as input.
0 Kudos
Message 3 of 5
(2,945 Views)
Travis, I just looked up the ActiveX document, and it is very clear - except that I don't know what ActiveX control I need to register. Is there a specific Excel ActiveX control, and if so, how do I find it?
0 Kudos
Message 4 of 5
(2,945 Views)
Hello Connie,

Which version of LabVIEW are you using and which version of MS Office do you have? You should not have to register any ActiveX controls as long as you have Excel installed. If you are getting this error in Open Excel.vi, I would suggest you try recreating the block diagram. Drop an Automation Open function from All Functions -> Communication -> ActiveX and create a control for the Automation Refnum input. Right click on this control terminal and choose Select ActiveX Class -> Excel._Application. You can rebuild the rest of the code using Property Nodes and Invoke Nodes. Also this Knowledge Base entry might be helpful: http://digital.ni.com/public.nsf/websearch/246B651C89F4AA2586256B1400656AE2?OpenDocument

For writing a table containing ASCII characters to an Excel file without using ActiveX, you can use Array to Spreadsheet String.vi and Write Characters to File.vi. I'm attaching a simple example that illustrates this.

Also, if you have the add-on Report Generation Toolkit, you might want to look at the shipping example Sample Report (Excel).vi that illustrates how to write tables to Excel.

Hope this helps and let me know if you have more questions regarding this.
Good luck and best regards,
Shakhina P.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(2,908 Views)