Hey guys,
First of all - Happy new 2018!
I've decided to start-off that year with some more
excel scripting practice (more specifically dealing with colors).
I was very surprised when I saw that the color pallete in Excel is not the same as in AutoCAD -
Say prompt for an ACI color from AutoCAD and apply it to some cell in excel:
(defun C:test
( / *error* clr xlapp xlwbs xlwbk xlsht xlcells xlrng xlint msg
)
; (and xlapp (vl-catch-all-apply 'vlax-invoke-method (list xlapp 'quit)))
); defun *error*
( (not (setq clr
(acad_colordlg
1 nil))) ) (
); lambda
); function
); vl-catch-all-apply
); setq msg
); vl-catch-all-error-p
)
); cond
); defun C:test
So does anyone know what type of color Excel uses? And how to convert from ACI/RGB to match it?
With VBA that color manipulation task looks very easy (but I guess that it might have the same ColorIndex issue) :
Range("A1").Interior.ColorIndex = 37
Range("A1").Interior.ColorIndex = 0
MsgBox Selection.Interior.ColorIndex
Range("A1").Interior.Color = RGB(255, 0, 0)
BTW the
Interior object supports
Color property aswell - not sure which one would be the right to use, just leaving this for reference:
; Interior: nil
; Property values:
; Application (RO) = #<VLA-OBJECT _Application 0000007c535314b8>
; Color = 1.67772e+07
; ColorIndex = -4142
; Creator (RO) = 1480803660
; Gradient (RO) = nil
; InvertIfNegative = Exception occurred
; Parent (RO) = #<VLA-OBJECT Range 0000007c4bf42688>
; Pattern = -4142
; PatternColor = 0
; PatternColorIndex = -4142
; PatternThemeColor = -4142
; PatternTintAndShade = 0.0
; ThemeColor = -4142
; TintAndShade = 0.0
; No methods