ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set color (vc++) (https://www.excelbanter.com/excel-programming/316944-set-color-vc.html)

vavshek

set color (vc++)
 

Hi,
I have to write an application in vc++ which will be processing exce
files. I already know how to put something in specific cell but I hav
no idea how to change a color of the cell. Do you know how to do this
Thanks for any tips and advices. Below I paste piece of code which
use to put somthing in the cell A1.

_Application objApp;
_Workbook objBook;
Workbooks objBooks;
Worksheets objSheets;
_Worksheet objSheet;
Range range;
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

objBooks = objApp.GetWorkbooks();
objBook = objBooks.Add(VOptional);
objSheets = objBook.GetWorksheets();
objSheet = objSheets.GetItem(COleVariant((short)1));

range = objSheet.GetRange(COleVariant("A1"),COleVariant("A 1"));
range.SetValue(COleVariant("aaa"))

--
vavshe
-----------------------------------------------------------------------
vavshek's Profile: http://www.excelforum.com/member.php...fo&userid=1651
View this thread: http://www.excelforum.com/showthread.php?threadid=31372


Bob Phillips[_6_]

set color (vc++)
 
Don't know vc++, but to set a colour, use

range.Interior.Colorindex=35

the number is the colour pallette index number.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"vavshek" wrote in message
...

Hi,
I have to write an application in vc++ which will be processing excel
files. I already know how to put something in specific cell but I have
no idea how to change a color of the cell. Do you know how to do this?
Thanks for any tips and advices. Below I paste piece of code which I
use to put somthing in the cell A1.

_Application objApp;
_Workbook objBook;
Workbooks objBooks;
Worksheets objSheets;
_Worksheet objSheet;
Range range;
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

objBooks = objApp.GetWorkbooks();
objBook = objBooks.Add(VOptional);
objSheets = objBook.GetWorksheets();
objSheet = objSheets.GetItem(COleVariant((short)1));

range = objSheet.GetRange(COleVariant("A1"),COleVariant("A 1"));
range.SetValue(COleVariant("aaa"));


--
vavshek
------------------------------------------------------------------------
vavshek's Profile:

http://www.excelforum.com/member.php...o&userid=16518
View this thread: http://www.excelforum.com/showthread...hreadid=313721





All times are GMT +1. The time now is 01:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com