I am new to this area. Could you please help me with a VBA macro command to save the content of a generated report to my computer with a specified name? Thank you!
This is what I have until now:
Sub RunSAPScript()
‘Helps to run faster
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Declare variables
Dim SapGuiAuto As Object
Dim SapApp As Object
Dim SapCon As Object
Dim session As Object
Dim I_Lines As Double
Dim Q_Lines As Double
Dim fso As Object
'Activate workbook and select sheet
ThisWorkbook.Activate
Sheets("Control Panel").Select
'Set Objects for SAP session
Set fso = CreateObject("Scripting.FileSystemObject")
Set SapGuiAuto = GetObject("SAPGUI")
Set SapApp = SapGuiAuto.GetScriptingEngine
Set SapCon = SapApp.Children(0)
Set session = SapCon.Children(0)
Q_Lines = Application.WorksheetFunction.CountA(Worksheets("Layout").Range("A1").EntireColumn)
'Maximize window
session.findById("wnd[0]").maximize
'Enter to T-Code (FAGLL03)
session.findById("wnd[0]/tbar[0]/okcd").Text = "/NFAGLL03"
session.findById("wnd[0]").sendVKey 0
'Add Account, Company Code, Dates & Layout
session.findById("wnd[0]/usr/ctxtSD_SAKNR-LOW").Text = "4600201300"
session.findById("wnd[0]/usr/ctxtSD_BUKRS-LOW").Text = "GBDZ"
session.findById("wnd[0]/usr/radX_AISEL").Select
session.findById("wnd[0]/usr/ctxtSO_BUDAT-LOW").Text = "01.06.2024"
session.findById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").Text = "30.06.2024"
session.findById("wnd[0]/usr/ctxtPA_VARI").Text = "RRB Check"
'Run
session.findById("wnd[0]/tbar[1]/btn[8]").press
'Restore application settings
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
I have tried to write this with chat gpt but it doesn’t work 🙂
Dinita Mircea is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.