GoExcel.NameRange ERROR: Public member 'GetLength' on type 'String' not found.

GoExcel.NameRange ERROR: Public member 'GetLength' on type 'String' not found.

Anonymous
Not applicable
696 Views
4 Replies
Message 1 of 5

GoExcel.NameRange ERROR: Public member 'GetLength' on type 'String' not found.

Anonymous
Not applicable

Hi,

 

I'm trying to update a MultiValue List using GoExcel.NameRangeValue in iLogic.

So far all worked well, when the name range had more than one row But getting an error: "Public member 'GetLength' on type 'String' not found." when that Range has less than two rows.

 

I'm a not a VBA coder by any stretch of the imagination but have dabbled in coding in other languages. I've used a code snippet from Xiaodong Liang that gets the job done when ranges are => 2 rows

 

Any help would be appreciated.

 

Here is my code:

SyntaxEditor Code Snippet

GoExcel.Open("CabSpecBook.xlsx", "Wall Cabinets")

'Code Snipet to read Name Range in Excel
    'this Is an array X*Y dimension
    rangeArray = GoExcel.NamedRangeValue("_15inHW1D")
    'create a list to get the values of the columns
    Dim oList As ArrayList
    oList = New ArrayList
    'rangeArray.GetLength(0)  means how many rows
    'rangeArray.GetLength(1)  means how many colmuns
    Dim oRowsCount
    oRowsCount = rangeArray.GetLength(0)
    Dim oColCount
    oColCount = rangeArray.GetLength(1)
    
    Dim oRowIndex As Integer
    Dim oColIndex As Integer
    For oRowIndex = 1 To oRowsCount  
    ' add value of each row one by one
    For oColIndex = 1 To oColCount 
        oList.Add(rangeArray(oRowIndex,oColIndex))
    Next 
    Next
    
    'Set it To the list Parameter
    MultiValue.List("CabModNum") = oList
    

iLogicVb.UpdateWhenDone = True

 

0 Likes
697 Views
4 Replies
Replies (4)
Message 2 of 5

Xun.Zhang
Alumni
Alumni

Hi, Try this.

GoExcel.Open("CabSpecBook.xlsx", "Wall Cabinets")

'Code Snipet to read Name Range in Excel
    'this Is an array X*Y dimension
    rangeArray = GoExcel.NamedRangeValue("_15inHW1D")
    'create a list to get the values of the columns
    Dim oList As ArrayList
    oList = New ArrayList
    'rangeArray.GetLength(0)  means how many rows
    'rangeArray.GetLength(1)  means how many colmuns
    Dim oRowsCount
    oRowsCount = rangeArray.GetLength(0)
    Dim oColCount
    oColCount = rangeArray.GetLength(1)
    
    Dim oRowIndex As String
    Dim oColIndex As String
    For oRowIndex = 1 To oRowsCount  
    ' add value of each row one by one
    For oColIndex = 1 To oColCount 
        oList.Add(rangeArray(oRowIndex,oColIndex))
    Next 
    Next
    
    'Set it To the list Parameter
    MultiValue.List("CabModNum") = oList
    

iLogicVb.UpdateWhenDone = True

Xun
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi,

 

Thanks for the follow-up.

 

I went over the code all night and it's the same as the previous one I had posted.

 

Mid going through the changes that were made in case I'm missing something?

 

Thank you

0 Likes
Message 4 of 5

kelly.young
Autodesk Support
Autodesk Support

@Anonymous the change I can see is that Integer is changed to String:

 

code.png

Please select the Accept as Solution button if a post solves your issue or answers your question.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Good morning,

 

This is the error I get when I run string instead of integer:

 

Error on Line 28 : 'For' loop control variable cannot be of type 'String' because the type does not support the required operators.
Error on Line 30 : 'For' loop control variable cannot be of type 'String' because the type does not support the required operators.

 

sorry for the late reply

0 Likes