Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Shape color index does not match cell color index

Hi All

I have writen some code so that a user can add a callout shape onto a
cell.

I would like to color the callout shape the same color as the cell the
user selected.

shp.Fill.ForeColor.SchemeColor = r.Interior.ColorIndex

However it seems that the SchemeColor for shapes DOES NOT equal the
ColorIndex used for cells.

Should I use a different property or is there a mapping? Or is this
too hard?

Cheers for any ideas,
Chrisso
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Shape color index does not match cell color index

Hi,

This may help you at least understand the problem.
http://spreadsheetpage.com/index.php...heme_colors/#c

Cheers
Andy

Chrisso wrote:
Hi All

I have writen some code so that a user can add a callout shape onto a
cell.

I would like to color the callout shape the same color as the cell the
user selected.

shp.Fill.ForeColor.SchemeColor = r.Interior.ColorIndex

However it seems that the SchemeColor for shapes DOES NOT equal the
ColorIndex used for cells.

Should I use a different property or is there a mapping? Or is this
too hard?

Cheers for any ideas,
Chrisso


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Shape color index does not match cell color index


Don't guarantee it will work but try the following:-

shp.Fill.ForeColor.RGB = r.Interior.Color

I was able to get it to work using the following test code so it might point
you in the right direction:-

ActiveSheet.Shapes("Rectangle 1").Select

Selection.ShapeRange.Fill.ForeColor.RGB = Range("A1").Interior.Color

--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Shape color index does not match cell color index

For IndexColor to SchemeColor add 7

If you are using Excel 97-2003 following should work (except CF colours will
override). Otherwise, sadly, the link Andy referred you to will explain some
of the difficulties.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim nIdx As Long
Dim shp As Shape

On Error GoTo errExit
Set shp = Me.Shapes("AutoShape 1") ' < name to suit
nIdx = Target(1).Interior.ColorIndex
If nIdx < 1 Then nIdx = 58
shp.Fill.ForeColor.SchemeColor = nIdx + 7

errExit:

End Sub

Regards,
Peter T

"Chrisso" wrote in message
...
Hi All

I have writen some code so that a user can add a callout shape onto a
cell.

I would like to color the callout shape the same color as the cell the
user selected.

shp.Fill.ForeColor.SchemeColor = r.Interior.ColorIndex

However it seems that the SchemeColor for shapes DOES NOT equal the
ColorIndex used for cells.

Should I use a different property or is there a mapping? Or is this
too hard?

Cheers for any ideas,
Chrisso



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Shape color index does not match cell color index

Thanks all posters - very useful and helpful information and links.

Cheers
Chrisso
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart axes color index vs font color index [email protected] Charts and Charting in Excel 4 December 7th 06 04:05 PM
Setting Background Color RGB (Always goes to closest index color) [email protected] Excel Programming 6 December 2nd 05 11:47 PM
Keep text color from a Index Match Formula Woody Excel Programming 4 July 21st 05 05:43 PM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
Identify Cell Color Index Voskre Excel Programming 7 July 25th 04 12:10 AM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"