Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get rgb out of ColorIndex value in excel
Message
From
12/12/2006 06:14:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/12/2006 05:47:21
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 6 SP5
Miscellaneous
Thread ID:
01176544
Message ID:
01176786
Views:
6
>>>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform