【问题标题】:SAP GUI scripting - Gridview - Find text in a given column and doubleclick the cellSAP GUI 脚本 - Gridview - 在给定列中查找文本并双击单元格
【发布时间】:2015-10-14 09:42:53
【问题描述】:

我正在使用 excel VBA 来尝试自动化一些 SAP 数据输入。

我有一个 gridview 控件,我试图在列中查找特定文本,然后双击该单元格以选择它。

我目前正在使用 for 循环来查找行,但得到了一些奇怪的结果。当我单步执行代码时,我可以到达该行但无法选择或双击它。当代码以通常的速度运行时,甚至没有选择行!

有没有更好的方法来解决这个问题?

这是目前为止的代码

 Function SelectRowOnGrid(grid As SAPFEWSELib.GuiGridView, columnname As String, texttofind As String) 

        For i = 0 To grid.RowCount - 1

            If grid.GetCellValue(i, columnname) = texttofind Then
                grid.DoubleClickCurrentCell
            End If

        Next i

End Function

我也试过下面的代码:

    Function SelectRowOnGrid(grid As SAPFEWSELib.GuiGridView, columnname As String, texttofind As String)

        For i = 0 To grid.RowCount - 1

          If InStr(1, grid.GetCellValue(i, columnname), texttofind, 1) > 0 Then

            If selectedRows = "" Then
              selectedRows = CStr(i)
                Else
              selectedRows = selectedRows + "," + CStr(i)
            End If

          End If

        Next i

    grid.selectedRows = selectedRows

End Function

感谢任何帮助!

干杯

【问题讨论】:

    标签: vba sap-gui


    【解决方案1】:

    你必须在双击之前选择单元格:

    If grid.GetCellValue(i, columnname) = texttofind Then
        grid.SetCurrentCell(i, columnname)
        grid.DoubleClickCurrentCell
    End If
    

    【讨论】:

      猜你喜欢
      • 2022-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-22
      • 1970-01-01
      • 2016-01-16
      • 1970-01-01
      相关资源
      最近更新 更多