?
Solved

VB.net Excel Add-In RGB Color

Posted on 2013-06-19
3
Medium Priority
?
575 Views
Last Modified: 2013-06-20
Hi

I have used the following code to color cells in my VSTO Excel Add-in
Globals.ThisAddIn.Application.Selection.Interior.color = RGB(200, 160, 35)

I am now using a Color Dialog control on a form and the value of the selected color
is given in the following format "Color [A=255, R=128, G=64, B=0]"
How do I color a cell using this format?
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 81

Assisted Solution

by:byundt
byundt earned 1000 total points
ID: 39260751
You might try parsing the string like this:
Sub ColorPicker()
Dim strColor As String
Dim iRed As Integer, iGreen As Integer, iBlue As Integer
strColor = "Color [A=255, R=128, G=64, B=0]"
iRed = Val(Mid(strColor, InStr(1, strColor, "R=") + 2))
iGreen = Val(Mid(strColor, InStr(1, strColor, "G=") + 2))
iBlue = Val(Mid(strColor, InStr(1, strColor, "B=") + 2))
Globals.ThisAddIn.Application.Selection.Interior.Color = RGB(iRed, iGreen, iBlue)
End Sub

Open in new window

Brad
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 1000 total points
ID: 39261748
The ColorDialog returns a Color object which has R G and B properties so you should be able to use (assuming C is your returned Color object)
Globals.ThisAddIn.Application.Selection.Interior.Color = RGB(C.R, C.G, C.B)

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 39261768
Thanks for the help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question