2014-06-10 2 views
0

VBS SAP 스크립트를 시작하고 VBS 코드의 일부 변수를 변경하기 위해 매크로를 작성하려고합니다. 어떤 도움이라도 좋을 것입니다! 아래로 내가 필요한 개체 오류VBS에서 VBS 실행 VBS Object 오류 필요

Public Sub SimpleSAPExport() 
Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object 
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI 
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected 
Set session = Connection.Children(0) 'Get the first session (window) on that connection 

' Start the transaction to view a table 
session.StartTransaction "SE16" 
end sub 
+1

각 "'설정 XXX ='"추가 :'XXX 아무것도 다음 "위의 것은 깨진"' –

+0

런타임 오류 '424' 개체 을 요구하고 VBA는 아래의 라인을 강조 MSGBOX없는 경우 세션 설정 = Connection.Children (0) – Formatted

답변

0

이 코드를 평가 해보십시오 :

Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object 
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI 
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected 
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection 

당신이 연결 istead에서 개체 SAPCon 누락 때문에 오류 메시지를 받고, 단지 가능성이 객체 코드를 실행하면 동일한 문제에 직면했으며이 객체를 변경하여 해결되었습니다.

보다도,

에드가 M.

여전히 에드가 M의 조언 후 문제를 끊으면
0

, 설정 세션 전에 약간의 지연을 추가
시도 .. (SAPConconnection를 수정) (또는 직전)이 경우 SAPCon은 (실행 환경 내에서) 코드 연속 전에 완료 할 수있는 충분한 시간을 갖습니다 (빠른 PC 취득과 관련하여?). 그래서 같은
:이 후

.. 
Set SAPCon = SAPApp.Children(0) 
WScript.Sleep 200 
Set session = SAPCon.Children(0) 

은, 임의의 정지가 넘는 것 같았다. 후
보다도, JanW