我有一个 python 脚本,它生成一个.bas
在 SAP GUI 上执行进程的文件。我假装每天都运行这个脚本来更新.bas
文件并运行它。
我放弃了使用驱动程序(如 selenium)直接操作 SAP GUI 的想法,因为代码太长,我应该重构所有代码。
我已经尝试过的解决方案是使用 VBA Interpreter SmallBasic,但出现错误:
- COMP-ERROR AT Main:10 *
描述:
(EXPR): SYNTAX ERROR (5)
该.bas
文件以:
Sub RPA_YVA05()
Application.DisplayAlerts = False
Dim SapGuiApp As Object
Dim oConnection As Object
Dim session As Object
Dim SAPCon As Object, SAPSesi As Object
Dim SAPGUIAuto As Object, SAPApp As Object
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If oConnection Is Nothing Then
Set oConnection = SapGuiApp.OpenConnection("xxxxxxxxxxxxxxxxxx", True)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
End If
'Application.DisplayAlerts = False
With SAPSesi
.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "0000"
.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "xxxxxxx"
这个生成的脚本已经在 Excel 上运行,但我想要一种比打开 Excel 文件并每天手动加载脚本更快的方法。请帮我