Hello,
I'm trying to save the excel file generated from SAP. Unfortunatly, I'm not able to save ite directly from SAP. SAP only allows to export the excel. The problem is that my macro doesn't find that generated file. Could you please help me to find solution?
I have alredy trieddifferent approaches, but cannot save opened export file:
'Worksheets(Workbooks.Count).SaveAs filename:=ThisWorkbook.Path & "\YE3.XLSX"
'Windows("Sheet1").SaveAs filename:=ThisWorkbook.Path & "\YE3.XLSX"
I'm trying to save the excel file generated from SAP. Unfortunatly, I'm not able to save ite directly from SAP. SAP only allows to export the excel. The problem is that my macro doesn't find that generated file. Could you please help me to find solution?
VBA Code:
Function ExportYE3(Groupname As String, Closingdate As Date, CompanyCode As String) As String
ExportYE3 = ExportYE3 & vbNewLine & " - " & Now() & " - ExportYE3 - Start for " & Groupname
On Error GoTo 112
'Start transaction
With Session
.StartTransaction "YE3"
'Input parameters
Session.findById("wnd[0]/usr/txtS_GJAHR-LOW").Text = Year(Closingdate)
Session.findById("wnd[0]/usr/ctxtS_PERIOD-LOW").Text = Month(Closingdate)
Session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").Text = CompanyCode
Session.findById("wnd[0]/usr/ctxtS_BU-LOW").Text = Groupname
Session.findById("wnd[0]/usr/radRB_EXC").SetFocus
Session.findById("wnd[0]/usr/radRB_EXC").Select
'Launch
Session.findById("wnd[0]").sendVKey 8
'Save - not working!!!
Worksheets(Workbooks.Count).Activate
ActiveWorkbook.SaveAs filename:=ThisWorkbook.Path & "\YE3.XLSX"
Exit Function
I have alredy trieddifferent approaches, but cannot save opened export file:
'Worksheets(Workbooks.Count).SaveAs filename:=ThisWorkbook.Path & "\YE3.XLSX"
'Windows("Sheet1").SaveAs filename:=ThisWorkbook.Path & "\YE3.XLSX"