LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Obtain current RGB settings for color indexes 17 thru 27

Sorry, I missed it somehow...I see how your method works...thanks for another
angle on this issue.

"Peter T" wrote:

quartz" wrote in message

I want to retrieve the current color mix values (RGB) for the current user
of an Excel file (for index 17 through 27) and store these settings in a
hidden sheet. I then plan to add some custom color mixes for use with a
program, then restore the user's original colors when the user exits the

file.

You don't need individual RGB values, just the Long colour value:
x = Activeworkbook.Colors(17)

When changing more than one palette colour it's much "smoother" to apply all
56 in one go. Here's a total package for you, albeit only for colours 17 &
18.

Sub SavePalette()
Dim i As Byte
Dim vArr, vMyColors
Dim rng As Range

ActiveSheet.Range("a1:bd1") = ActiveWorkbook.Colors
vArr = ActiveWorkbook.Colors

vMyColors = Array(13097698, 12229775)
For i = 0 To 1
vArr(i + 17) = vMyColors(i)
Next
ActiveWorkbook.Colors = vArr

End Sub

Sub RestorePalette()
ActiveWorkbook.Colors = ActiveSheet.Range("a1:bd1").Value
End Sub

Obviously set a reference to a similar sized range in your hidden sheet,
enlarge the vMyColors array and loop to suit. Note vArr is "one base" and
vMyColors "zero base" (unless you've set Option Base).
Alternatively, you can save and restore the palette to a Named array, which
could be hidden.

To convert your own RGB to a Long
x = rgb(226,218,199)

Regards,
Peter T



 
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
Vlookup using concatenated column indexes Matt Excel Worksheet Functions 7 June 9th 08 02:07 AM
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
how can one obtain the current selected cell value Susan Hayes Excel Programming 3 December 14th 04 10:31 AM
multiple chart indexes Jack Excel Programming 1 August 4th 04 05:26 AM
Figuring out what the Shape Indexes are. Jeff Reed Excel Programming 1 August 21st 03 11:44 PM


All times are GMT +1. The time now is 04:05 AM.

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

About Us

"It's about Microsoft Excel"