LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing text color in Excel using ActiveX

I would like to do this without using a macro.
0 Kudos
Message 1 of 4
(3,346 Views)
If you have CVI 6.0 or later, you can use the Excel Report instrument driver (excelreport.fp) located in the "\toolslib\activex\excel" directory or the "\samples\activex\excel" directory.

The following call should do what you want:

ExcelRpt_SetCellRangeAttribute (
worksheetObjHandle, "A1",
ER_CR_ATTR_FONT_COLOR, MakeColor(0,255,0));
0 Kudos
Message 2 of 4
(3,346 Views)
Hi,

You can do this by taking advantage of the ActiveX Controller Wizard in CVI. First, run the wizard under Tools >> Create ActiveX Controller. This will generate an instrument driver for you to access Excel objects, methods, and properties. Then, in your application, you can call these ActiveX function panels to perform your operations. One function you might use is SetProperty. You can use this to find and set the color property for your font. If you want to do this for a range of cells, you may have to do it through setting the font color property for the range object. However, at this point, our support is limited because we are getting into the ActiveX programming interface defined by Microsoft. It would be best for you to search the msdn website for
the ActiveX properties and methods for Excel to know what's available to you. Some small examples are shipped with CVI. Just open up the Example Finder and search for 'ActiveX'. These examples were created specifically for Excel 97 and 2000, and they utilize the ActiveX interface defined for each. If you are using another version of Excel, then you should create your own ActiveX Controller as suggested above and then see what functionality is offered. Every version of Office has a slightly different ActiveX interface. Hope this helps!

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 3 of 4
(3,346 Views)

Anyone ever figure out the right command for this? I would think it would be something along the lines of

 

ErrorCode = Excel_SetProperty (CellHandle, &ErrorInfo, Excel_FontColor, CAVT_VARIANT, ???);

but I sure can't make it work no matter what I do.

 

It seems a simple thing, I'm reading and writing to worksheets fine, making new ones etc. so the ActiveX link is working great. There's just a dearth of ActiveX information for even the simplest of functions in CVI 😞

0 Kudos
Message 4 of 4
(2,042 Views)