cancel
Showing results for 
Search instead for 
Did you mean: 

SAP VBA code with coordinates

Former Member
0 Kudos

Hello Folks,

i would like to ask for your help in fixing this code.

i have recorded step is sap and i got this code:

session.findById("wnd[0]/usr/tblSAPLZZVWPM79_CANCWO2TCTRL_ZZVWPM79_CANCWO2/txtZZVWPM79_CANCWO2-IWERK[0,0]").Text = "TEST1"

Now, what i want is replace the value of "0,0" into an integer since i have multiple lines to set-up. i have now below code but it is not running.

sub TEST()

Dim a As Integer

Dim b As Integer

    a = 0

    b = 0

session.findById("wnd[0]/usr/tblSAPLZZVWPM79_CANCWO2TCTRL_ZZVWPM79_CANCWO2/txtZZVWPM79_CANCWO2-IWERK[a,b]").Text = "TEST1"


a = i + 1

b = z + 1

Loop

end sub

Please help!

Thanks,

Michael

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Michael,

like Holger wrote to use variables you should change your code:

sub TEST()

Dim a As Integer

Dim b As Integer

a = 0     'Column

b = 0     'Row


Do


session.findById("wnd[0]/usr/tblSAPLZZVWPM79_CANCWO2TCTRL_ZZVWPM79_CANCWO2/txtZZVWPM79_CANCWO2-IWERK[a," & b &"]").Text = "TEST1"


'a = a + 1

b = b + 1

Loop Until b = 4

end sub

This code will fill in the first 4 rows in column 0 (the first column) with the same value TEST1.

holger_khn
Contributor
0 Kudos

Hello.

Are you sure you want to move both coordinates?

The column mostly will be fixed value. So you just Need to make row variable dynamic (in your case 'a').

script_man
Active Contributor
0 Kudos

Hi Michael,

You can try the following:

session.findById("wnd[0]/usr/tblSAPLZZVWPM79_CANCWO2TCTRL_ZZVWPM79_CANCWO2/txtZZVWPM79_CANCWO2-IWERK[" & cstr(a) & "," & cstr(b) & "]").Text = "TEST1"


Regards,

ScriptMan