Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get rgb out of ColorIndex value in excel
Message
From
15/12/2006 01:50:27
 
 
To
12/12/2006 06:14:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 6 SP5
Miscellaneous
Thread ID:
01176544
Message ID:
01177879
Views:
8
That is a sample!!
Thank you very much.
I 'reserve right' to bug you more these days :) since I am
cooking something with Excel and Pdf automations...



>>>>OLE experts,
>>>>Is there simple way to get RGB values out of color index value in
>>>>excel?
>>>>
>>>>TIA
>>>
>>>nColor = oExcel.ActiveWorkbook.Colors(nColorIndex)
>>>
>>>Cetin
>>
>>Did not hv time to implement it yet
>>but it will probably work as usual :)
>>Thks++
>
>Here is a quick check code:)
>
>Create Cursor xlColors (colorIndex i, rgbval c(15),ncolor i)
>oExcel = Createobject("Excel.Application")
>With oExcel
>  .Workbooks.Add
>  For ix = 1 To 56
>    Insert Into xlColors ;
>      (colorIndex, rgbval, ncolor) ;
>      VALUES ;
>      ( m.ix, ;
>      rgbstring( .ActiveWorkbook.ColorS(m.ix) ),;
>      .ActiveWorkbook.ColorS(m.ix))
>  Endfor
>  .Quit
>Endwith
>Locate
>
>Public oForm
>oForm = Createobject('Form')
>oForm.AddObject('myGrid','grid')
>oForm.myGrid.Columns(3).DynamicBackColor = "xlColors.ncolor"
>oForm.myGrid.Columns(3).DynamicForeColor = "xlColors.ncolor"
>oForm.myGrid.Visible = .T.
>oForm.Show
>
>Function rgbstring
>  Lparameters tnColor
>  Local lnRed,lnGreen,lnBlue
>  lnRed	= Bitrshift(Bitand(m.tnColor, 0x0000FF),0)
>  lnGreen	= Bitrshift(Bitand(m.tnColor, 0x00FF00),8)
>  lnBlue	= Bitrshift(Bitand(m.tnColor, 0xFF0000),16)
>  Return Trans(m.lnRed)+","+Trans(m.lnGreen)+","+Trans(m.lnBlue)
>
>PS: Colors is readwrite. You can change default palette IOW.
>Cetin
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform