SAP GUI脚本:VBA的新会议

发布于 2025-02-12 18:19:22 字数 577 浏览 2 评论 0原文

我正在搜索当前会话运行时打开新会话的宏脚本。

问题是,宏仅在打开时打开了新的会话,但是在按下执行按钮后,当前会话正在运行示例事务时,不会进行新的会话。

下面我的宏:

Private Sub nextSession()

Dim nSessions As Integer

Set SapGuiAuto = GetObject("SAPGUI")

Set SAPApp = SapGuiAuto.GetScriptingEngine

Set sapCon = SAPApp.Children(0)

Set session = sapCon.Children(0)

nSessions = sapCon.Sessions.Count

session.CreateSession

Do

    Application.Wait (Now() + 500 * ms)

    If sapCon.Sessions.Count > nSessions Then Exit Do

Loop

Set sapSession = sapCon.Sessions.Item(CInt(sapCon.Sessions.Count - 1))

End Sub

I am searching for macro script that opens new session when current session is running.

Problem is that macro opens new session when it's only opened, but not makes new session when current session is running example transaction after pressing execute button.

My macro below:

Private Sub nextSession()

Dim nSessions As Integer

Set SapGuiAuto = GetObject("SAPGUI")

Set SAPApp = SapGuiAuto.GetScriptingEngine

Set sapCon = SAPApp.Children(0)

Set session = sapCon.Children(0)

nSessions = sapCon.Sessions.Count

session.CreateSession

Do

    Application.Wait (Now() + 500 * ms)

    If sapCon.Sessions.Count > nSessions Then Exit Do

Loop

Set sapSession = sapCon.Sessions.Item(CInt(sapCon.Sessions.Count - 1))

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文