Jump to content

Recommended Posts

Posted (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 by golfinhu
Posted

Just a guess...("BK1:BP255")?

  Reveal hidden contents
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."

 

WindowsError.gif

  Reveal hidden contents

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

Posted
  On 5/14/2015 at 11:37 PM, golfinhu said:

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:

  Reveal hidden contents

 

Posted
  On 5/15/2015 at 6:36 AM, water said:

​What do you mean by: Don't work? Could you please be a bit more specific?

​Look my generic code:

 

#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)
EndIf

I can't get an color array like a data array!

Posted

As far as I know: ColorIndex (and other properties) only accepts or returns a single value.
I'm nor sure how ColorIndex behaves:

  1. You only will get this single value when all cells of the Range have the same color, else you will get Null.
  2. You get the value for the upper left cell of the Range

Which one is true needs to be tested.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 5/16/2015 at 2:57 AM, lorenkinzel said:

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!!!

 

  On 5/16/2015 at 8:02 AM, water said:

As far as I know: ColorIndex (and other properties) only accepts or returns a single value.
I'm nor sure how ColorIndex behaves:

  1. You only will get this single value when all cells of the Range have the same color, else you will get Null.
  2. You get the value for the upper left cell of the Range

Which one is true needs to be tested.

​i understand, thanks a lot for you explanation and help!

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

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
×
×
  • Create New...