+ Reply to Thread
Results 1 to 8 of 8

Obtain current RGB settings for color indexes 17 thru 27

  1. #1
    quartz
    Guest

    Obtain current RGB settings for color indexes 17 thru 27

    I am using Office 2003 on Windows XP.

    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.

    Does anyone have a function that will retrieve the current color mixes
    (RGB)? If so, could you please post example code or a function? (Please note
    that I already know how to custom mix the colors and add them to the palette,
    access them, etc). OR if someone has an easier solution to this issue, please
    post any suggestions...

    Thanks much in advance.


  2. #2
    Bob Phillips
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    Sub test()
    Dim red, green, blue
    GetRGB ActiveWorkbook.Colors(17), red, green, blue
    Debug.Print red
    Debug.Print green
    Debug.Print blue
    End Sub

    Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)

    red = colour And &HFF
    green = colour \ 256 And &HFF
    blue = colour \ 256 ^ 2 And &HFF

    End Function


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "quartz" <quartz@discussions.microsoft.com> wrote in message
    news:283AC350-F1B1-4EB4-8877-D3AEC5FBB8C4@microsoft.com...
    > I am using Office 2003 on Windows XP.
    >
    > 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.
    >
    > Does anyone have a function that will retrieve the current color mixes
    > (RGB)? If so, could you please post example code or a function? (Please

    note
    > that I already know how to custom mix the colors and add them to the

    palette,
    > access them, etc). OR if someone has an easier solution to this issue,

    please
    > post any suggestions...
    >
    > Thanks much in advance.
    >




  3. #3
    quartz
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    Thanks Bob.
    Forgive my ignorance, but how can I get this info into cells in a sheet?


    "Bob Phillips" wrote:

    > Sub test()
    > Dim red, green, blue
    > GetRGB ActiveWorkbook.Colors(17), red, green, blue
    > Debug.Print red
    > Debug.Print green
    > Debug.Print blue
    > End Sub
    >
    > Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)
    >
    > red = colour And &HFF
    > green = colour \ 256 And &HFF
    > blue = colour \ 256 ^ 2 And &HFF
    >
    > End Function
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "quartz" <quartz@discussions.microsoft.com> wrote in message
    > news:283AC350-F1B1-4EB4-8877-D3AEC5FBB8C4@microsoft.com...
    > > I am using Office 2003 on Windows XP.
    > >
    > > 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.
    > >
    > > Does anyone have a function that will retrieve the current color mixes
    > > (RGB)? If so, could you please post example code or a function? (Please

    > note
    > > that I already know how to custom mix the colors and add them to the

    > palette,
    > > access them, etc). OR if someone has an easier solution to this issue,

    > please
    > > post any suggestions...
    > >
    > > Thanks much in advance.
    > >

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    What exactly do you want to retrieve, the separate red green blue
    components, the colour value, or what? Separate cells, all in one? How will
    you pass the colour to be evaluated?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "quartz" <quartz@discussions.microsoft.com> wrote in message
    news:9976B88B-1ACF-4DE7-B221-0FF5777F38B3@microsoft.com...
    > Thanks Bob.
    > Forgive my ignorance, but how can I get this info into cells in a sheet?
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Sub test()
    > > Dim red, green, blue
    > > GetRGB ActiveWorkbook.Colors(17), red, green, blue
    > > Debug.Print red
    > > Debug.Print green
    > > Debug.Print blue
    > > End Sub
    > >
    > > Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef

    blue)
    > >
    > > red = colour And &HFF
    > > green = colour \ 256 And &HFF
    > > blue = colour \ 256 ^ 2 And &HFF
    > >
    > > End Function
    > >
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "quartz" <quartz@discussions.microsoft.com> wrote in message
    > > news:283AC350-F1B1-4EB4-8877-D3AEC5FBB8C4@microsoft.com...
    > > > I am using Office 2003 on Windows XP.
    > > >
    > > > 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.
    > > >
    > > > Does anyone have a function that will retrieve the current color mixes
    > > > (RGB)? If so, could you please post example code or a function?

    (Please
    > > note
    > > > that I already know how to custom mix the colors and add them to the

    > > palette,
    > > > access them, etc). OR if someone has an easier solution to this issue,

    > > please
    > > > post any suggestions...
    > > >
    > > > Thanks much in advance.
    > > >

    > >
    > >
    > >




  5. #5
    Peter T
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    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



  6. #6
    quartz
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    Nevermind Bob, I figured it out...

    For lngX = 17 To 27
    GetRGB ActiveWorkbook.Colors(lngX), argRed, argGreen, argBlue
    ActiveSheet.Range("A1:C1").Offset(lngX - 17, 0).Value = Array(argRed,
    argGreen, argBlue)
    Next lngX

    Thanks much.

    "quartz" wrote:

    > Thanks Bob.
    > Forgive my ignorance, but how can I get this info into cells in a sheet?
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Sub test()
    > > Dim red, green, blue
    > > GetRGB ActiveWorkbook.Colors(17), red, green, blue
    > > Debug.Print red
    > > Debug.Print green
    > > Debug.Print blue
    > > End Sub
    > >
    > > Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)
    > >
    > > red = colour And &HFF
    > > green = colour \ 256 And &HFF
    > > blue = colour \ 256 ^ 2 And &HFF
    > >
    > > End Function
    > >
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "quartz" <quartz@discussions.microsoft.com> wrote in message
    > > news:283AC350-F1B1-4EB4-8877-D3AEC5FBB8C4@microsoft.com...
    > > > I am using Office 2003 on Windows XP.
    > > >
    > > > 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.
    > > >
    > > > Does anyone have a function that will retrieve the current color mixes
    > > > (RGB)? If so, could you please post example code or a function? (Please

    > > note
    > > > that I already know how to custom mix the colors and add them to the

    > > palette,
    > > > access them, etc). OR if someone has an easier solution to this issue,

    > > please
    > > > post any suggestions...
    > > >
    > > > Thanks much in advance.
    > > >

    > >
    > >
    > >


  7. #7
    quartz
    Guest

    Re: Obtain current RGB settings for color indexes 17 thru 27

    Thanks Peter, but your method doesn't allow me to first get the current
    settings. i.e. if the user has already mixed some custom colors of their own,
    I need to get those so I can reset them when the user closes my program
    file...

    You did supply some helpful info though, such as how to convert to a long.
    Thanks again.

    "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
    >
    >
    >


  8. #8
    quartz
    Guest

    Re: 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
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1