Skip to content

Instantly share code, notes, and snippets.

@fergus
Last active January 4, 2016 04:19
Show Gist options
  • Save fergus/8567876 to your computer and use it in GitHub Desktop.
Save fergus/8567876 to your computer and use it in GitHub Desktop.
This function returns accepts a string of three comma separated values and converts these to a Long value suitable for use in Excel.
Function Convert-RGBtoLong
(
[string] $RGBString = "0,160,175" #Teal
)
{
$RGBLong = ([int]$RGBString.split(",")[2] *65536) + ([int]$RGBString.split(",")[1]*256) + [int]$RGBString.split(",")[0]
Write-Verbose "Convert-RGBtoLong: $RGBString = $RGBLong"
$RGBLong;
<#
.DESCRIPTION
Function Convert-RGBtoLong accepts a string of three comma seperated values and converts these to a Long value suitable for use in Excel.
.PARAMETER RGBString
String of three comma seperated values
.EXAMPLE
$connection = Convert-RGBtoLong ("198,217,45")
.OUTPUTS
long colour value
.NOTES
NAME: Convert-RGBtoLong
AUTHOR: Fergus Stevens
LASTEDIT: 30 Jan 2014
.LINK
https://gist.github.com/fergus/8567876
#Requires -Version 2.0
#>
}
@fergus
Copy link
Author

fergus commented Mar 4, 2014

The long colour values have also been tested in Word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment