一些SAP脚本中的运行时错误'619'

时间:2019-12-13 08:28:35

标签: excel vba

我收到了这个超级烦人的运行时错误,提示

  

“无法通过ID找到该控件。”

但是,宏可以正常工作。每次使用时,我只需要单击“结束”即可。
你能发现什么地方不对吗?

编辑:我把剩下的代码放进去了。

If Not IsObject(SAPGuiApp) Then
   Set SapGuiAuto = GetObject("SAPGUI")
   Set SAPGuiApp = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
   Set Connection = SAPGuiApp.Children(0)
End If
If Not IsObject(SAP_session) Then
   Set SAP_session = Connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject SAP_session, "on"
   WScript.ConnectObject SAPGuiApp, "on"
End If

Set xclapp = GetObject(, "Excel.Application")
Set xclsht = ActiveWorkbook.ActiveSheet

For i = 2 To xclapp.ActiveCell.SpecialCells(11).Row
 For j = 1 To xclapp.ActiveCell.SpecialCells(11).Column
  If j = 1 Then DATEONE = xclsht.Cells(i, j).Value
  If j = 2 Then DATETWO = xclsht.Cells(i, j).Value
  If j = 3 Then Price = xclsht.Cells(i, j).Value
 Next

SAP_session.findById("wnd[0]").resizeWorkingPane 210, 29, False
SAP_session.findById("wnd[0]/tbar[0]/okcd").Text = "ZV"
SAP_session.findById("wnd[0]").sendVKey 0
SAP_session.findById("wnd[0]/usr/ctxtP_TAB").Text = "VB"
SAP_session.findById("wnd[0]/usr/txtP_MAX").Text = ""
SAP_session.findById("wnd[0]/usr/ctxtP_TAB").caretPosition = 4
SAP_session.findById("wnd[0]").sendVKey 0
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-LOW[2,16]").Text = "0,01"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-LOW[2,17]").Text = "EUR"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-LOW[2,18]").Text = "Y100"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-LOW[2,19]").Text = "02"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,16]").Text = "2.500"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,19]").Text = "04"
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,19]").SetFocus
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,19]").caretPosition = 2
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC").verticalScrollbar.Position = 9
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-LOW[2,19]").Text = DATEONE
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,19]").Text = DATETWO
SAP_session.findById("wnd[1]/usr/tblSAPLSE16NMULTI_OR_TC/ctxtGS_MULTI_OR-HIGH[3,19]").caretPosition = 10
SAP_session.findById("wnd[1]/tbar[0]/btn[0]").press

Next
MsgBox "All " & CStr(xclapp.ActiveCell.SpecialCells(11).Row - 1) & " Excel rows have been processed."

Set xclwbk = Nothing
Set xclsht = Nothing
xclapp.Quit

Set xclapp = Nothing

End Sub

0 个答案:

没有答案