my problem is that the exported excel files open after the macro is finished. I couldn’t solve the problem with the other articles. Has anybody an idea?
Sub Makro()
Dim SapGuiAuto, Application, Connection, session As Object
' First I just open SAP and insert the string'
session.findById("wnd[2]/usr/ctxtDY_PATH").Text = "C:\TEMP"
session.findById("wnd[2]/usr/ctxtDY_FILENAME").Text = "EXPORT_" & i & ".XLSX"
session.findById("wnd[2]/tbar[0]/btn[11]").Press
session.findById("wnd[1]").Close
session.findById("wnd[0]/tbar[0]/btn[3]").Press
Range("B3").Select
Selection.Copy
Workbooks.Open ("C:\TEMPEXPORT_" & i & ".XLSX")
Windows("EXPORT_" & i & ".XLSX").Activate
Set mp = Range("B3")
eintragmp = Mid(mp.Value, 1, 2)
Windows("SAP Verknüpfung.xlsx").Activate
Cells(i, 6) = eintragmp
Workbooks("EXPORT_" & i & ".XLSX").Close SaveChanges:=False
' filePath = "C:TEMPEXPORT_" & i & ".XLSX"
' If Dir(filePath) <> "" Then
' Kill filePath
Else
Windows("SAP Verknüpfung.xlsx").Activate
Cells(i, 6) = "Fertig"
If Cells(i, 6) = "Fertig" Then
Cells(i, 7) = "Umlauf"
End If
End If
On Error GoTo 0
Next i
session.findById("wnd[0]/tbar[0]/btn[3]").Press
Set Application = Nothing
Set session = Nothing
Set Connection = Nothing
End Sub
I tried multiple prompts to close the files but nothing worked out.
The best would be if it wouldn’t open itself.
New contributor
Ginger Ale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.