Quisiera pedir un poco de ayuda con la captura de texto desde una ventana flotante de SAP. Estoy trabajando con script de SAP y macro excel.
al final del script, traté de guardalo en una variable text, pero me trae el texto de la cabecera de la ventana principal y no de la mas pequeña.
Sub GenFacturaNexiq()
Dim application
Dim connection
Dim userID
Dim GridView As Object
referencia = Range("B8")
importe = Range("D8")
ceco = Range("G8")
sucursal = Range("E8")
LicName = Range("C8")
Set objsheet = ActiveWorkbook.ActiveSheet
fecha = Range("A8")
fechaDocumento = Format(fecha, "dd.mm.yyyy")
div = Range("F8")
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.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 application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "fb01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtBKPF-BLDAT").Text = fechaDocumento
session.findById("wnd[0]/usr/ctxtBKPF-BLART").Text = "KR"
session.findById("wnd[0]/usr/ctxtBKPF-BUKRS").Text = "1000"
session.findById("wnd[0]/usr/ctxtBKPF-WAERS").Text = "usd"
session.findById("wnd[0]/usr/txtBKPF-XBLNR").Text = referencia
session.findById("wnd[0]/usr/ctxtRF05A-NEWBS").Text = "31"
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").Text = "602"
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").SetFocus
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").caretPosition = 3
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtBSEG-WRBTR").Text = importe
session.findById("wnd[0]/usr/ctxtBSEG-GSBER").SetFocus
session.findById("wnd[0]/usr/ctxtBSEG-GSBER").caretPosition = 0
session.findById("wnd[0]/usr/ctxtBSEG-GSBER").Text = div
'session.findById("wnd[0]").sendVKey 4
'session.findById("wnd[1]/usr/lbl[1,27]").SetFocus
'session.findById("wnd[1]/usr/lbl[1,27]").caretPosition = 2
'session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/usr/ctxtBSEG-ZLSPR").Text = "A"
session.findById("wnd[0]/usr/ctxtBSEG-KIDNO").Text = "P"
session.findById("wnd[0]/usr/ctxtBSEG-SGTXT").Text = "Factura" & " " & referencia
session.findById("wnd[0]/usr/ctxtRF05A-NEWBS").Text = "40"
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").Text = "312420030"
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").SetFocus
session.findById("wnd[0]/usr/ctxtRF05A-NEWKO").caretPosition = 9
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtBSEG-WRBTR").Text = importe
session.findById("wnd[0]/usr/ctxtBSEG-MWSKZ").Text = "C0"
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-GSBER").SetFocus
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-GSBER").caretPosition = 0
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-GSBER").Text = div
'session.findById("wnd[0]").sendVKey 4
'session.findById("wnd[1]/usr/lbl[1,26]").SetFocus
'session.findById("wnd[1]/usr/lbl[1,26]").caretPosition = 1
'session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-KOSTL").SetFocus
'CENTRO DE COSTO
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-KOSTL").Text = ceco
session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-KOSTL").caretPosition = 0
'session.findById("wnd[0]").sendVKey 4
'session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB002/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[0,24]").Text = "*post*"
'session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB002/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[0,24]").caretPosition = 6
'session.findById("wnd[1]").sendVKey 0
'session.findById("wnd[1]").Close
'session.findById("wnd[0]/usr/subBLOCK:SAPLKACB:1007/ctxtCOBL-GSBER").Text = ""
......... .........
session.findById("wnd[0]/usr/txtBSEG-ZUONR").Text = "Taller" & " " & sucursal
session.findById("wnd[0]/usr/ctxtBSEG-SGTXT").Text = "Licencia" & " " & LicName
'session.findById("wnd[0]/usr/ctxtBSEG-SGTXT").SetFocus
session.findById("wnd[0]/usr/ctxtBSEG-SGTXT").caretPosition = 32
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/mbar/menu[0]/menu[3]").Select
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/sbar").DoubleClick
myText = session.findById("wnd[0]").Text
'Ejemplo
'myText = session.findById("wnd[1]/usr/cntlCC1/shellcont/shell").Text
'myText = Right(myText, 9)
Range("H8") = myText
End Sub