cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to scroll GUI table in VB

Former Member
0 Likes
15,036

Hi

I'm having trouble with a GUI table automation through VB (GuiTableControl.)

What is the best way to run though each row in a table - if i want to extract all values in a table not

just those displayed on the screen.

eg 4 rows are display on the screen. But if the table contain more entries, how do I move the

table to the fifth row.

oidtable.verticalScrollbar.Position = 4 ' fifth row..

sometime works and other times crashes..

is there a better way to move through all items one by one...not just the ones displayed..

The rows collection , contains rows on the screen.

This can get rows but again it only work for the four rows displayed on the screen rows (0-3)

oidtable.rows.item(3).item(0).text

how do i get the fifths row in a table..

mike.

View Entire Topic
Former Member

I recently faced with a similar situation with the GuiTableControl.

A colleague wanted to extract data from a table which only have 2 visible rows whereas there are 2000+ rows in total. My first thought, like yours, was to use VerticalScrollBar.Position to scroll down the table, but the script crashes after it completed the 1st loop.

After trial and error with different strategies, my VBA script finally works. The key is to re-declare the GuiTableControl object after each scroll. It seems that whenever the VerticalScrollBar position changes, the table is re-loaded is SAP and all the cells are reset in reference to the VerticalScrollBar position. This is probably why SAP throw an exception when trying to get the value from the table after the 1st loop - the GuiTableControl declared initially no longer exist in memory after the scroll.

Anyway, my solution steps are basically as follow:

  1. Declare the GuiApplication, GuiConnection and GuiSession objects as usual for initialization.
  2. Declare the GuiTableControl object e.g. sapTable = session.findbyid("theTableID"), then get the sapTable.VisibleRowCount and sapTable.RowCount.
  3. Set the looping parameters to start from whichever rows but maximum loops should be no more than RowCount / VisibleRowCount.
  4. Get the data using sapTable.GetCell(0,0).Text to maximum sapTable.GetCell( VisibleRowCount - 1, Columns.Count - 1).Text
  5. Set sapTableVerticalScrollBar.Position = sapTable.VerticalScrollBar.Position + sapTable.VisibleRowCount.
  6. Re-declare the sapTable object using the same "theTableID" in step 2 above.
  7. Loop step 4, 5 and 6 until finish.

This way, we eliminate the need to use VBS for Sendkey and only needs VBA to do the job.

Thanks,

Sayuti

Stefan-Schnell
Active Contributor
0 Likes

Hello Sayuti,

thanks for sharing this interesting information

Cheers

Stefan