Hi I am new to Python scripting, I wrote a code for SAP GUI automation but at last excel file open so I want to close that file.
I need a help regarding code to check if specific Excel file is already open, if open then closing the same using Python.
Thanks for help in advance.
I am using below code:
with open('C:\\Users\\Xyz\\AppData\\Local\\Temp\\export.XLSX', 'r') as f:
f.close()
Also if someone can hep me converting VBA function in Python and can tell me how to call the same.
Function WKopen(wb As String) As Boolean
On Error Resume Next
WKopen= Len(Workbooks(wb).Name)
End Function
Sub BK_Close()
On Error Resume Next
If WkOpen("Export_Download.XLSX") Then
Workbooks("Export_Download.xlsx").Close savechanges:=False
Else
End If
End Sub