luckyluke Posted June 10, 2012 Posted June 10, 2012 (edited) Hello I get problem with excel cell color. I'm trying to use this code: #include <ExcelCOM_UDF.au3> $oExcel = _ExcelBookNew() $oExcel.ActiveWorkbook.Sheets(1).cells(1,1).Interior.Color = "RGB(255, 0, 0)" this code work in VB excel And i got this error: C:Documents and SettingsbinhngoDesktopautoitexhtml.au3 (73) : ==> The requested action with this object has failed.: $oExcel.ActiveWorkbook.Sheets(1).cells(1,1).Interior.Color = "RGB(255, 0, 0)" $oExcel.ActiveWorkbook.Sheets(1).cells(1,1).Interior^ ERROR when i try use $oExcel.ActiveWorkbook.Sheets(1).cells(1,2).Interior.Color = 702623 ;or $oExcel.ActiveWorkbook.Sheets(1).cells(1,2).Interior.ColorIndex = 16 it's worked. But the problem here is: i have 6 digit hex color and i can only convert it to RGB color (for ex:d6834d). how can i set RGB color for excel cell using Autoit, please help Edited June 10, 2012 by luckyluke
luckyluke Posted June 10, 2012 Author Posted June 10, 2012 (edited) I just found a solution: Color = (256 * 256 * B) + G * 256 + R this is how excel convert RGB to string. Thanks all Edited June 10, 2012 by luckyluke robertocm 1
MC256 Posted August 13, 2013 Posted August 13, 2013 (edited) I got confused by the non-standard ordering of luckyluke's formula (BGR vs. RGB). I think it's more natural when written in RGB order, as most people are used to: R + (G*256) + (B*256*256) I assigned the result of this calculation to: $range.interior.color = ... Edited August 15, 2013 by MC256
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now