>>Looking at the generated macro, I think I can assign a .ColorIndex from 1 to 40, representing 40 different colors. It doesn't look as if
>>I can assign an arbitrary rgb() value. (Is this correct?)
>>The question I had was mainly, how could or should this be designed? For a start, I think that if a certain class (i.e., the same
>>subject, for the same group of students) is held, for example, Monday and Thursday, I would like to color both cells with the same
>>color.
>>Should I assign random colors each time I run the Excel report? Perhaps trying to to repeat colors (assuming there are less than
>>40 classes)? Should I let the user store the color index in the table, together with the student classes? Or perhaps pre-assign a
>>random value in the table, but let the user change it? (I'll probably have to consult whether they want similar courses in the same
>>color, e.g. different courses for "Computer Networking, Semester 4" in the same color).
Before Excel 2007, you must use an indexed colour, I think there are actually 56 (Including White & Black). Excel 2007 has many more colours, but unfortunately I don't get to use them because many of my clients still have earlier versions.
The following code will create a spreadsheet showing you the 56 colours and their index value:
#define xlSolid 1
loExcel=CREATEOBJECT("Excel.Application")
loExcel.workbooks.Add()
loSheet1=loExcel.Workbooks(1).Worksheets.add
loSheet1.Select()
FOR lnk=1 TO 56
WITH loSheet1
lcRow=ALLTRIM(STR(lnk))
.Range("A"+lcRow).Value=lnk
.Range("B"+lcRow).Interior.ColorIndex = lnk
.Range("B"+lcRow).Interior.PATTERN = xlSolid
ENDWITH
ENDFOR
loExcel.Visible=.T.
Personally I would create a lookup table of course titles and assign colours to those, you could then give them a way of manually amending. don't forget you have both text colour and fill colour.
Gary.