我的应用程序生成具有不同动态工作表名称的Excel工作表。我想设置这个公式'Laden van de data uit transactie IW28 naar de sheet
Dim lastcolumn As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'SAP Variant
SapVariant = "Variant"
'Transaction
Name = IW28
'Current File Location
Map = Application.ActiveWorkbook.Path
If Not IsObject(SapApp) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SapApp = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SapApp.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 SapApp, "on"
End If
'Check if file is already open, if so then close the file
If IsOpen(Name & ".xlsx") = True Then Workbooks(Name & ".xlsx").Close
'Open Transaction
session.findById("wnd[0]/tbar[0]/okcd").Text = "/N" & Name
session.findById("wnd[0]").sendVKey 0
'Choose Variant
On Error Resume Next
session.findById("wnd[0]/mbar/menu[2]/menu[0]/menu[0]").Select
session.findById("wnd[1]/usr/txtV-LOW").Text = SapVariant
'Check if variant excists
If Not Err.Number = 0 Then
VarMsgbox = MsgBox("Selecteer variant " & SapVariant & ", dubbelklik om deze te selecteren en klik dan hieronder op ok (niet eerder!)", vbOKCancel, "Selecteer variant")
If VarMsgbox = vbCancel Then Exit Sub
Else
session.findById("wnd[1]/usr/txtENAME-LOW").Text = ""
session.findById("wnd[1]/usr/txtV-LOW").caretPosition = 10
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]").sendVKey 8
End If
'Execute Variant
session.findById("wnd[0]").sendVKey 8
'Select all data in SAP
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectAll
'Export to Excel
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/tbar[0]/btn[0]").press
'Add filename and path
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = Name & ".xlsx"
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = Map
session.findById("wnd[1]/tbar[0]/btn[11]").press
'Determine lastrow of sheet
Lastrow = Workbooks(Name & ".xlsx").Sheets("Sheet1").Range("B99999").End(xlUp).Row
ThisWorkbook.Sheets(Name).Range("A8:C99999").ClearContents
Workbooks(Name & ".xlsx").Sheets("Sheet1").Range("A2:C" & Lastrow).Copy
ThisWorkbook.Sheets(Name).Range("A8").PasteSpecial xlPasteValues
ThisWorkbook.Sheets("Start").Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
对于所有在 Print_Area 中具有动态工作表名称的工作表。如何在EP Plus中实现这一目标?