Skip to Content
-1

How to know how many rows GuiTableControl has

Jan 24 at 04:47 PM

51

avatar image
Former Member

Hi, I'm doing a macro in excel and I need to know how you can go through all rows of GuiTableControl to store the information of the channels in my Excel cells

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Daniel McCollum Jan 25 at 06:32 AM
0

- Something like this

'Found the pattern matched table, assign to tObj for item maintenance
Set tobj = session.FindById(tGuiTableControl)
Set tObjChild = tobj.Children


' Count the array length (dimension 1)
tDataRows = UBound(tData, 1)
' Count the array width (dimension 2)
'tDataColumns = UBound(tData, 2)
' Count the target table width, since thats what we are populating values across.
tDataColumns = tobj.Columns.Count
visiblerows = tobj.VisibleRowCount


tDataLoopRow = 1
tDataLoopColumn = 1
tObjRow = 0
tObjItemNum = 0


Do                                                          'Loop over pages to update in depth
    Do While tObjRow < visiblerows                          'Loop over the rows to update in a page
        Do While tDataColumns >= tDataLoopColumn            'Loop over the columns to update in a row
            If tData(tDataLoopRow, tDataLoopColumn) <> "" Then
                If tObjChild.Item(tObjItemNum + 0).Type = "GuiCTextField" Or tObjChild.Item(tObjItemNum + 0).Type = "GuiTextField" Then
                    If IsDate(tData(tDataLoopRow, tDataLoopColumn)) = True Then
                        If tData(tDataLoopRow, tDataLoopColumn) = #12/31/1899# Then 'excel dates in the deep past are weird due to Lotus 1-2-3
                            tObjChild.Item(tObjItemNum + 0).text = DateConvert(tData(tDataLoopRow, tDataLoopColumn) + 1, ".")
                        Else:
                            tObjChild.Item(tObjItemNum + 0).text = DateConvert(tData(tDataLoopRow, tDataLoopColumn), ".")
                        End If
                    Else:
                        tObjChild.Item(tObjItemNum + 0).text = tData(tDataLoopRow, tDataLoopColumn)
                    End If
                ElseIf tObjChild.Item(tObjItemNum + 0).Type = "GuiComboBox" Then
                    tObjChild.Item(tObjItemNum + 0).Key = tData(tDataLoopRow, tDataLoopColumn)
                    
                ElseIf tObjChild.Item(tObjItemNum + 0).Type = "GuiCheckBox" Then
                    tObjChild.Item(tObjItemNum + 0).Selected = True
                Else:
                    'other conditions
                End If
            End If
            
            'Are we exiting the updates?
            If tData(tDataLoopRow, 1) = "" Then
                tDataFinished = "X"
                Exit Do
            End If
                    
            tObjItemNum = tObjItemNum + visiblerows
            tDataLoopColumn = tDataLoopColumn + 1


        Loop
        'Are we exiting the updates?
        If tDataFinished = "X" Then
            Exit Do
        End If
        'check if we should commit current batch
        If CommitAfterX > 0 Then
            If tDataLoopRow Mod CommitAfterX = 0 Then
                Call commitCurrentUpdates(session, TargetTable, tTargetTransport)
                'Reset the Obj Update index
                tObjRow = -1
                'Reset the pattern matched table, assign to tObj for item maintenance
                Set tobj = session.FindById(tGuiTableControl)
                Set tObjChild = tobj.Children
            Else:
                x = y
            End If
        End If
        tDataLoopColumn = 1
        tDataLoopRow = tDataLoopRow + 1
        tObjRow = tObjRow + 1
        tObjItemNum = tObjRow
    Loop
    tObjRow = 1
    tObjItemNum = 1
    
    'set next row in preparation for either commit, or next page of visible rows
    session.FindById("wnd[0]/mbar/menu[2]/menu[2]").Select
    'check & manage data entry issues.
    Call PreSaveHandler(session)
   
    'Reset the pattern matched table, assign to tObj for item maintenance
    Set tobj = session.FindById(tGuiTableControl)
    Set tObjChild = tobj.Children
    
Loop Until tDataFinished = "X"

- I made this to maintain tables via SM30. You can probably rip out what you need to read the table contents inversely.

Share
10 |10000 characters needed characters left characters exceeded