Author Topic: change excel cell colour  (Read 1442 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
change excel cell colour
« on: March 25, 2013, 10:32:40 AM »
Hello there,

I'm still in the excel problems, i would like to change the background of a cell, like in VBA
Code: [Select]
Range("A1:A6").Interior.Color = RGB(200,160,35)

is thee a similar thing in vlisp?

Thanks,


Bernd

VVA

  • Newt
  • Posts: 166
Re: change excel cell colour
« Reply #1 on: March 25, 2013, 11:44:04 AM »
Try it
Code: [Select]
(vl-load-com)
(setq OEX (vlax-get-or-create-object "Excel.Application")) ;_Object Excell
(setq OWRB (vlax-get-property OEX 'Workbooks))             ;_Object Workbook
(setq AWB (vlax-invoke-method OWRB 'Add))                    ;_Active Workbook
(setq ASH (vlax-get-property AWB "Worksheets"))            ;_Active WorkSheet
(setq MySheet (vlax-invoke-method ASH 'Add))                 ;_Sheet
(vlax-put-property OEX "Visible" :vlax-true)
(setq cell (vlax-variant-value                                              ;_Range
             (vlax-invoke-method
               MySheet
               "Evaluate"
               "A1:A6"
             ) ;_ end of vlax-invoke-method
           ) ;_ end of vlax-variant-value
) ;_ end of setq
(setq obj (vlax-get-property cell 'Interior)) ;_Interior
(vlax-put-property obj 'Colorindex 6)          ;_Color
(vlax-release-object obj)
(vlax-release-object cell)
(vlax-release-object MySheet)
(vlax-release-object ASH)
(vlax-release-object AWB)
(vlax-release-object OWRB)
(vlax-release-object OEX)

Amsterdammed

  • Guest
Re: change excel cell colour
« Reply #2 on: March 26, 2013, 01:35:13 PM »
 Perfect!!!!:-D

Thanks,

Bernd