Jump to content

Can i change cell color in excel with autoit ?


Recommended Posts

Hi all,

I have a work book which contained some date values. So each time i opened this book, i need to change the back ground color of cells which will come under a specific criteria. Say, cells which contained the date value of current month. I know how to find a specific range of cells. But i don't know how to change the color programatically.  

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Hello,
 
Hope this helps:
 
#include <EXCEL.AU3>
Local $oAppl = _Excel_Open(True, False, True, True, True)
Local $oWorkbook = _Excel_BookNew($oAppl, 1)

With $oAppl.ActiveWorkbook.Sheets(1)
.Range("A1:A1").Interior.Color = 0x330099
EndWith

 

 
Please note that color codes in excel are BGR and not RGB
 
Other fun commands:
.Range("A1:A1").Font.Bold = True
.Range("A1:A1").Font.Color = 0xFFFFFF
.Range("A1:A1").Borders.Color = 0x000000
Edited by Kinshima
Link to comment
Share on other sites

@Kinshima

Wow.. Thanks a  lot. Let me try this. :)

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@Kinshima,

Yes, it worked. And now i am searching for a BGR color chart

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

  • 2 years later...

Warning.  Old thread but its the fist one I found that mentions the swap.

 

Can anyone tell me why the swap is needed.     I've been using ColorIndex and just tried Color instead to get a better shade.   In playing around before coming here I discovered the need for the swap.  It works .... buy why?

_ColorSetRGB()

says RGB in the help file but only gives me the results I want if I use BGR when I use the result in

.Range('A1').Interior.Color

 

Am I misreading the help file or misreading the Microsoft site?
It works fine but I don't know why.

I was reading from here.
https://msdn.microsoft.com/en-us/library/cc296089(office.12).aspx

Its not 2007.  I'm using office 365 but the code seems to be the same.  Is this the difference?  Does newer excel versions need it backwards.   That would be odd.  I'm sure its something else I overlooked.

 

Edited by cal
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...