问题描述
SAP GUI 代码 CreateSession 当我添加 Microsoft Outlook 16.0 对象库时,永远不会创建会话。如果我删除了 Outlook 引用,它就可以正常工作。
outlook 代码位于另一种表单上,此表单的用户不使用,因此不会执行。
由于这个问题是在 2010 年在 SAP 网站上于 2010 年发现的,没有其他问题,我将假设它的编写方式是这样的。
我正在使用 SAP GUI 脚本 API
Microsoft Outlook 16.0 对象库
SAP 版本为 7.50
谢谢
彼得
Session_number_max = 5 'the maximum number of possible SAP sessions
Dim session_number_(5)
On Error Resume Next
Set SapGuiAuto = Getobject("SAPGUI")
Set SAP = SapGuiAuto.GetScriptingEngine
Set Connection = SAP.Children(0)
Set session = Connection.Children(0)
'------------------------------------------- new session connect -------------------------------------------------------------
session_number_all = Connection.Children.Count - 1
If Connection.Children.Count = 0 Then
'MsgBox ("Couts =") & session_number_all
'GoTo Erreur
End If
For i = 0 To Session_number_max - 1
session_number_(i) = 0
Next
For session_number = 0 To session_number_all
Set session = Connection.Children(Int(session_number))
session_number_(session.Info.SessionNumber) = session.Info.SessionNumber
Next
If session_number_all < Session_number_max - 1 Then
Do
trycount = trycount + 1
session.CreateSession '#### this ends up in an infinite loop as CreateSession never creates a valid session. ####
'WScript.sleep 500
If Connection.Children.Count - session_number_all >= 2 Then Exit Do '#### this ends up in an infinite loop as
If trycount >5 then
exit loop
GoTo Errorcode
end if
Loop
On Error Resume Next
Error_number = 1
For session_number = 0 To session_number_all + 1
Err.Clear
Set session = Connection.Children(Int(session_number + 1))
If Err.Number > 0 Or Err.Number < 0 Then Exit For
'MsgBox (" Session = ") & session_number
If session_number_(session.Info.SessionNumber) = 0 Then
Error_number = 0
Exit For
End If
'session.findById("wnd[0]").iconify 'So you can send another SAP session in the task bar.
Next
On Error GoTo 0
Else
MsgBox "Nouvelle session pas possible!"
End If
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)