[英]How to vary data using SAP and vba?
首先,我能够将 SAP GUI 连接到 vba。 我设法获得了一个有效的脚本,并向我发送了一个自动交易。 我想知道如何在 SAP 上输入数据,例如日期是可变的,因为我必须每年更改日期?
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]/usr/tabsTABSTRIP_TABBL1/
tabpUCOM1/ssub%_SUBSCREEN_TABBL1:RFBILA00:0001/txtBILBJAHR").text = "2015"
例如,我希望“2015”日期是可变的,我希望每个月我都可以更改此日期以放置另一个日期,而无需再次在 SAP GUI 上开始提取。
像这样,您还应该缩进代码:
Option Explicit
Sub Test()
Dim MyYear As String
MyYear = Format(Date, "yyyy")
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Application.Children(0)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject Session, "on"
WScript.ConnectObject Application, "on"
End If
Session.findById("wnd[0]/usr/tabsTABSTRIP_TABBL1/tabpUCOM1/ssub%_SUBSCREEN_TABBL1:RFBILA00:0001/txtBILBJAHR").Text = MyYear
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.