LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set fill color of Excel using activeX?

with Font>Color I can set the font color in Excel using activeX, my question is how to set the background color, or called fill color of a cell of the entire row/column with activeX, thx in advance.


"I think therefore I am"
0 Kudos
Message 1 of 9
(6,140 Views)

The fill colour of a cell or a range of cells is changed using the Colorindex or Color property of the Range.Interior object.

ColorIndex required an integer 1-56 representing a colour from the default colour pallette

Color expects a long integer usually generated by the RGB(Red, Green, Blue) function in Excel

 

Interior.PNG

 

Good Luck

 

Ken 

 

0 Kudos
Message 2 of 9
(6,107 Views)

Thanks a lot!

 

do you have a document help to know how to set all property of Excel, just as below (some example):

 

单元格设定背景色
objExcelSheet.Cells(3.1).Interior.colorindex=17
 合并单元格
objExcelSheet.Range(“A1:G7”).Merge


"I think therefore I am"
0 Kudos
Message 3 of 9
(6,097 Views)

My development strategy is to write (or record) a VBA Macro which does what I want it to do, using the Excel Help as a reference to methods and properties thatI am unfamiliar with, then convert it to LabVIEW AxtiveX.  I dont think that there is a help document in LabVIEW.

 

Ken

Message 4 of 9
(6,088 Views)

ELI2011 wrote:

 

do you have a document help to know how to set all property of Excel


That's like asking someone to explain every feature of a programming language.  I agree with the record a macro, then replicate the code in LabVIEW method.

 

There have been several toolkits wrote for Excel, the Report Generation Toolkit is pretty decent, and now comes with LabVIEW 2014 (I think Full and Pro).  Or there are some older toolkits like this one that still have value and is free.

0 Kudos
Message 5 of 9
(6,035 Views)

The Report Generation Toolkit is only available for free in LabVIEW Pro.  In LabVIEW Full its still an add on at £430Smiley Sad

Message 6 of 9
(6,022 Views)

it`s great, thanks!


"I think therefore I am"
0 Kudos
Message 7 of 9
(5,992 Views)

excuse me, can you help to parse following Macro to LabVIEW? THX!

 

Sub Macro1()
'
' Macro1 Macro
'

'
Range("R10").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=12"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Rows("12:12").Select
ActiveWindow.FreezePanes = True
End Sub


"I think therefore I am"
0 Kudos
Message 8 of 9
(5,953 Views)

Thats a complicated set of instructions to have LabVIEW carry out! 

 

Are you wanting to do this multiple times or just once per run.  If doing this only once per run, say during initialisation or setup of your Excel worksheet, I would apply all the formatting in Excel and save it as a template and then open the template from LabVEIW.

 

Ken

0 Kudos
Message 9 of 9
(5,928 Views)