Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Excel with Visual C++ 6.0 (need a graph control that behaves as much like the one in CVI as possible)

I hate to beat this to death but I was unable to find a clear answer to this question.  Does NI provide Excel control from within Visual C++ 6.0? 

I read that NI supports the ANSI-C library only for Visual C++ 6.0 users:

Thread : "Re: Benifits of using measurment studio for VC++ 6.0?"
NI REP : drohacek
Quote  : "we made the decision to support Visual C++ 6.0 users only through the ANSI-C interface and not through the Measurement Studio MFC-based class libraries."

If there is a suggested way of controlling Excel from within Measurement Studio for Visual C++ 6.0 then I’d love to know it.  If not, can a plain statement be made basically stating that if you want to control Excel you can’t use a Visual C++ 6.0 environment even with Measurement Studio support?

With .NET of course you can just decide to have Excel support added during project creation.  CVI can act as an ActiveX server and easily control Excel just by building off the examples shipped with CVI.  I see that there is support, using the Measurement Studio for Visual C++ 6.0 Project Wizard, for taking existing CVI projects and converting them to Visual C++ 6.0 projects or for calling CVI libraries from a .dll from within Visual C++ 6.0.  I suppose I could do the work in CVI and then convert the project but I'm so deeply tied into all my MFC calls that I don't see how I can cleanly include the CVI libraries into my existing VC++ 6.0 projects.

What I'm really after here is a visual graph control like the one in CVI that I can use from Visual C++ 6.0.  I purchased a 3rd party graph control for use in VC++ 6.0 that works well but isn't really visual.  I mean you can't enter any values in it until you run the program and fill it out programmatically.  Then you can see which columns are two narrow, quit the program, adjust the column width of your now empty control, and repeat, until you get the thing looking the way you want.  If I could call into Excel from within Visual C++ 6.0  the way I do from within .NET then I could use Excel to hold the table and just read in the values into my table control at run time.  Basically I'd use Excel as a visual development tool for all my tables.

I do all my coding from within CVI and Measurement Studio for Visual C++ 6.0.  I'd use CVI for everything if I didn't depend so heavily on certain outside controlled C++ .dll's.  Could you please suggest then what I can do to get Excel support for Visual C++ 6.0?

Last question :

Is there any plan to ever have a NI table control like the CVI table control for use in Visual Studio?  One that you can completely set up before you do any compiling?  I imagine that the way Microsoft sets up their environment makes this idea impossible.  Otherwise someone would have come up with a truly “visual” table control before now.

Thanks,

Grant
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 1 of 3
(12,257 Views)
Hello Grant

You can most certainly use Excel with VC++ 6.0. Measurement Studio won't provided you with any classes to talk to Excel in VC++ 6.0. This is because Excel allows control via Automation and you can use its automation API to do anything you need with Excel. This is what CVI uses as well.

You can see this MSDN article on how to set this up. This mentions VC.NET, but it should work the same way.

Here is one that talks about VC 6.0 and Excel.

Here is a code project article about this.

Even with .NET, you have to do thru the Excel Automation support. Excel started shipping with Primary Interop Assemblies (PIA) which are .NET wrappers about the Excel Automation object model. C++ Automation is definetely not as nice as .NET, BTW

See this document for more information about the Excel object model.

I would not recommend using the CVI Excel libraries if all you want to use them for is Excel automation. You will end up creating un-necessary dependencies and go through extra layers that way. You can make calls straight to Excel from VC++ without requiring CVI.

One quick observation about your excel approach. If you decide to use Excel as your table, you might be requiring everyone who uses your application to have Excel installed on their machines. Just wanted to make sure this was acceptable to you.

Have you looked at the Datagrid Activex control, which is one of the common controls that ships with Visual Studio? You can add it to Visual Studio by right-clicking and picking it from the list of installed activex control. If you have not already, you should check it out.

Microsoft has made significant improvements in the number of controls they provide with .NET. They have a Datagrid control that seems to be what you need.

Measurement Studio did add some high level classes for Excel and Word Automation that simplify some common tasks, but these exists for VS 2003 C++ and VS 2005 C++, not for VC 6.0. Underneath, we end up using the same Excel automation classes, so you can easily setup something similar for VC 6.0. Plus you can find alot of references online on how to use the Excel Automation object model with C++.

We currently have no plans in Measurement Studio to create a table control unfortunately. I am assuming when you said graph, you actually meant table, since Measurement Studio already  provides a ActiveX graph controls for VC++ 6.0 that is very similar to the CVI graph.

On a side note, VC++ 6.0 is really really old. Have you considered upgrading?

To summarize
- Yes, you can use Excel with Vc++ 6.0 without mstudio.
- Try using the Datagrid Activex control if you just need a table.
- Measurement Studio provides high-level excel and word classes for VC++ 6.0
- Measurement Studio provides a graph control for VC++ 6.0 which is very similar to the CVI graph.
- Measuremnt Studio does not have a table control.
- VC++ 6.0 is really really old. Have you considered upgrading?

Bilal Durrani
NI
Message 2 of 3
(12,244 Views)
Thanks Bilal.

As usual you know what I mean as opposed to what I actually write down.  This is great advice and I hope that this thread can get some wide exposure.  I bet I'm not the only one who has legacy VC++ 6.0 code to support and is trying to get up the nerve to jump all the way into a .NET environment. 

Keep up the great work.

Sincerely,

Grant

Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 3 of 3
(12,238 Views)