View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default How do I convert from a 'double' valued color to a System.Drawing.Color?

Nathaniel,

BTW:
I hope you're familiar with the difference between colorindex and
color.. colorindex is a pointer to the Workbook's .Colors array.

in VBA i'd use a collection object (with on error resume next) to build
a collection of all used colors...

Sub ColorIndex()
Dim itm As Variant
Dim cell As Range
Dim colColors As Collection

Set colColors = New Collection
On Error Resume Next
For Each cell In ActiveSheet.UsedRange.Cells
With cell.Interior
colColors.Add .ColorIndex, CStr(.ColorIndex)
End With
Next
For Each itm In colColors
Debug.Print itm, ActiveWorkbook.Colors(itm), _
Hex(ActiveWorkbook.Colors(itm))
Next
End Sub

Can you translate to C# ? <bg


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Nathanial Langman wrote:

Hi Tom,

Stepping back a moment... The big picture of my effort was to be able
to write a simple add-in for Excel in C# that could read through a
sheet an create an index of the unique cell colors that it
encountered. This seems like it should be much easier, so I can't
help feel like I missing the fundamentals.

I truly appreciate the advice, thank you.
Nat

PS. Are there any books about programming C# add-ins for office that
you might recommend? Thanks again.





*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!