Bonjour à tous,
J'ai un petit souci.
J'ai une appli access avec un code qui suivant une information, ouvre des fenêtres SAP, capture des informations et rempli Access.
J'ai ajouté une nouvelle fonctionalité et là patatra...
« The control could not be found by id »
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Sub CollectCMS()
Dim Connection As Object
Dim OTSelection As String
Dim OTPoste_Selection As String
Dim OTMAG_Selection As String
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set App = SapGuiAuto.GetScriptingEngine
If Not IsObject(App) Then
Exit Sub
End If
Set Connection = App.Children(0)
If Not IsObject(Connection) Then
Exit Sub
End If
Set session = Connection.Children(0)
If Not IsObject(session) Then
Exit Sub
End If
'Me.CMSNumber_Selection.Value = "Searching ..."
'Dim InputMag As String
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nlt21" 'appel de la transaction SAP LT21
session.findById("wnd[0]").sendVKey 0 'entrée
session.findById("wnd[0]/usr/txtLTAK-TANUM").Text = Forms("F001_Display_Dispatch_Photos").OTSelection.Value ' remplissage de SAP à l'aide des champs se trouvant dans access
session.findById("wnd[0]/usr/txtRL03T-TAPOS").Text = Forms("F001_Display_Dispatch_Photos").OTPoste_Selection.Value ' remplissage de SAP à l'aide des champs se trouvant dans access
session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").Text = Forms("F001_Display_Dispatch_Photos").OTMAG_Selection.Value ' remplissage de SAP à l'aide des champs se trouvant dans access
session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").SetFocus
session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").caretPosition = 3
session.findById("wnd[0]").sendVKey 0 'entrée
'focus sur le champ du cms
session.findById("wnd[0]/usr/ctxtLTAP-MATNR").SetFocus
'selection du champ cms
session.findById("wnd[0]/usr/ctxtLTAP-MATNR").caretPosition = 0
'selection du champ CMS et copie dans le champ du formulaire access
Forms("F001_Display_Dispatch_Photos").CMSNumber_Selection.Value = session.findById("wnd[0]/usr/ctxtLTAP-MATNR").Text
session.findById("wnd[0]/tbar[0]/okcd").Text = "AZSO" '
session.findById("wnd[0]").sendVKey 0 'entrée
session.findById("wnd[0]/usr/ctxtLTAK-TBNUM").SetFocus
session.findById("wnd[0]/usr/ctxtLTAK-TBNUM").caretPosition = 5
Forms("F001_Display_Dispatch_Photos").USMNumber_Selection.Value = session.findById("wnd[0]/usr/ctxtLTAP-ABLAD").Text
End Sub |
Le problème se présente (F8 pas à pas) sur la ligne
session.findById("wnd[0]/usr/ctxtLTAK-TBNUM").SetFocus
le "AZSO" est une fenêtre que j'ouvre sur la base d'un autre fenêtre.
Si quelqu'un a une idée...
Merci
Totor
Partager