如何用python友好地更新和运行.bas文件?

xienkqul  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(208)

我有一个python脚本,它生成一个.bas文件,在sapgui上执行一个进程。我假装每天都运行这个脚本来更新.bas文件并运行它。
我讨论了使用驱动程序(比如selenium)直接操作sapgui的想法,因为代码太长,我应该重构所有代码。
我已经尝试过的解决方案是使用vba解释器smallbasic,但出现了一个错误:


* COMP-ERROR AT Main:10 *

Description:
(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文件并手动加载脚本更快的方法。请帮帮我

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题