Bonjour,
Je suis en train de contruire une macro excel + un script me permettant de récupérer les informations de pricing d'une commande de vente.
Aucun problème quand la condition de prix ZPP1 existe cela fonctionne :


If Not IsObject(anApplication) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set anApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = anApplication.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject anApplication, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "va03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = NUM_CDE
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:8083/subSUBSCREEN_TC:SAPMV45A:8086/tblSAPMV45ATCTRL_U_ERF_AUFTROIL/txtRV45A-KWMENG[2,0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:8083/subSUBSCREEN_TC:SAPMV45A:8086/tblSAPMV45ATCTRL_U_ERF_AUFTROIL/txtRV45A-KWMENG[2,0]").caretPosition = 12
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\07").Select
Cells(1, 1).Value = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\07/ssubSUBSCREEN_BODY:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/ctxtKOMV-KSCHL[1,0]").Text
session.findById("wnd[0]/tbar[0]/btn[15]").press

TEST_ZPP1 = Range(Cells(1, 1), Cells(1, 1)).Value

Je pensais faire un test ensuite pour vérifier que la ZPP1 était bien présent dans la commande de vente...
Mais si il n'y a pas de ZPP1 mais une ZPD1 la zone porte le même nom KOMV-KSCHL, mais ne se trouve plus en [1,0] mais en [0,0] (j'aurais du m'en douter...) du coup la macro plante....
Un moyen (peut-être plus simple) pour savoir si la condition de prix ZPP1 est présente ?

D'avance merci