cancel
Showing results for 
Search instead for 
Did you mean: 

How to Select Items on Tcode ME52N with VBA Script

SAMBECKO
Discoverer
0 Kudos
119

Hi Dears,

kindly help I want to select an item on T-Code ME52N with reference to the range C5 but when in macro it doesn't work. Thank you in advance.

here is the macro:

Private Sub ME52N_Click()
Dim ComboBoxValue As String
ComboBoxValue = ThisWorkbook.Sheets("PROFILE INDICATOR").Range("C5").Value
 
Session.FindById("wnd[0]").maximize
Session.FindById("wnd[0]/tbar[0]/okcd").Text = "/NME53N"
Session.FindById("wnd[0]").sendVKey 0
Session.FindById("wnd[0]").sendVKey 17
Session.FindById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-BANFN").Text = Range("C4").Value
Session.FindById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-BANFN").caretPosition = 8
Session.FindById("wnd[1]").sendVKey 0
Session.FindById("wnd[0]").sendVKey 7
Session.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").SetFocus
 
'the problem is here:
Session.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").Key = ComboBoxValue
 
End Sub
 
 

Accepted Solutions (0)

Answers (1)

Answers (1)

rspecht
Explorer

Did you switch on the checkbox under "Options - Interaction Design - Visualization - Show keys within dropdown lists"? Otherwise try the property "Value" instead of "Key".

Also it would be a good idea to tell, WHICH problem you have.