LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

change cell color excel automation

I would like to change the cell color in excel2000 using the excel Automation. The color should be set dynamically in the code and not using macros in the excel sheet.
0 Kudos
Message 1 of 7
(3,711 Views)
Select the Cell Range that you want with the WorksheetRange function. Get the property for the range object called Interior. The Interior object is an object that gives you and interface to the fill effects in the interior of that range. You can then set the color property of the interior object for that range to be the color you want.

Hope that helps.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 7
(3,711 Views)
Thanks, however, I still cannot make the thing work.
Is it possible to provide me with a sample code? I am not sure if I am using the right commands in CVI.

I am basing my code on the CVI example excel2000dem. Does it make a difference if I interface to office XP instead of 2000?

Thanks
0 Kudos
Message 3 of 7
(3,711 Views)
Office XP shouldn't make a difference. If you will post your code, I will be happy to look at it and try and find why it isn't working.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 7
(3,711 Views)
Please find attached the .c,.h and .uir files of a sample program I constructed based on excel2000dem.prj.

Thanks very much for the interest.

Raphael
Download All
0 Kudos
Message 5 of 7
(3,711 Views)
You have an error in your code. On line 354, you have:

error = Excel_GetProperty (ExcelRangeHandle, NULL, Excel_AppSheets, CAVT_SHORT,&ExcelInteriorHandle);

You are trying to get the Excel_AppSheets property of the Range object. You should be getting the Interior property on the Range. That's why you are getting an error. If you correct that line to be:

error = Excel_GetProperty (ExcelRangeHandle, NULL, Excel_RangeInterior, CAVT_OBJHANDLE, &ExcelInteriorHandle);

You're program will work.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 6 of 7
(3,711 Views)
Thanks a lot.

You were of great help.

Regards,
Raphael
0 Kudos
Message 7 of 7
(3,711 Views)