golfinhu Posted May 14, 2015 Share Posted May 14, 2015 (edited) Hi all, fine?i need a little help!I need to get an array with the colors of the cells in the specified range! i've tried this, but don't work! Local $aCellColors = $oWorkbook.ActiveSheet.Usedrange.Columns("BK:BP").ColorIndex MsgBox(0,'',IsArray($aCellColors)) anyone help me? thanks a lot! Edited May 17, 2015 by golfinhu Link to comment Share on other sites More sharing options...
nitekram Posted May 15, 2015 Share Posted May 15, 2015 Just a guess...("BK1:BP255")? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
water Posted May 15, 2015 Share Posted May 15, 2015 i've tried this, but don't work!What do you mean by: Don't work? Could you please be a bit more specific? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
golfinhu Posted May 15, 2015 Author Share Posted May 15, 2015 What do you mean by: Don't work? Could you please be a bit more specific?Look my generic code: expandcollapse popup#include <Array.au3> $oExcel = ObjCreate("Excel.Application") With $oExcel ; open new workbook .Visible = True .WorkBooks.Add .ActiveWorkbook.Sheets(1).Select() EndWith $sRange ="A1:G8" With $oExcel.ActiveSheet.Range($sRange) .Select .HorizontalAlignment = -4108 ; center .ColumnWidth = 18 ;.EntireColumn.AutoFit EndWith ;Color Cells Local $n = 1 For $i = 1 To 7 For $j = 1 To 8 $oExcel.ActiveSheet.Range(Chr(64 + $i) & $j).Interior.ColorIndex = $n $oExcel.ActiveSheet.Range(Chr(64 + $i) & $j).value = "Color " & $n $n+=1 Next Next ;Array of cell values: Local $aValue = $oExcel.ActiveSheet.Range($sRange).value _ArrayDisplay($aValue) ;Array of cell colors: Local $aColors = $oExcel.ActiveSheet.Range($sRange).Interior.ColorIndex If Not IsArray($aColors) Then MsgBox(0,'','failed to get array colors') Else _ArrayDisplay($aValue) EndIfI can't get an color array like a data array! Link to comment Share on other sites More sharing options...
lorenkinzel Posted May 16, 2015 Share Posted May 16, 2015 Incomplete but:;For $i = 1 To 7 ;etc Local $theRange = (Chr(64 + 2) & 2) With $oExcel $theColor = .ActiveSheet.Range($theRange).Interior.ColorIndex EndWith Msgbox(0, "", $theColor) ;Next golfinhu 1 Link to comment Share on other sites More sharing options...
water Posted May 16, 2015 Share Posted May 16, 2015 As far as I know: ColorIndex (and other properties) only accepts or returns a single value.I'm nor sure how ColorIndex behaves:You only will get this single value when all cells of the Range have the same color, else you will get Null.You get the value for the upper left cell of the RangeWhich one is true needs to be tested. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
golfinhu Posted May 17, 2015 Author Share Posted May 17, 2015 Incomplete but:;For $i = 1 To 7 ;etc Local $theRange = (Chr(64 + 2) & 2) With $oExcel $theColor = .ActiveSheet.Range($theRange).Interior.ColorIndex EndWith Msgbox(0, "", $theColor) ;Next it's work, thanks a lot!!! As far as I know: ColorIndex (and other properties) only accepts or returns a single value.I'm nor sure how ColorIndex behaves:You only will get this single value when all cells of the Range have the same color, else you will get Null.You get the value for the upper left cell of the RangeWhich one is true needs to be tested.i understand, thanks a lot for you explanation and help! Link to comment Share on other sites More sharing options...
water Posted May 17, 2015 Share Posted May 17, 2015 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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