But if you use OS. System (' taskkill/im Microsoft Excel (32-bit)/F ') is unable to distinguish between the closing process is a background process or application
Has this requirement because I hope in does not affect the normal use excel spreadsheets reception under the premise of using the python call excel macro, use method is
XlApp=win32com. Client. DispatchEx (" Excel. Application ")
XlApp. Visible=False
XlApp. DisplayAlerts=0
XlBook=xlApp. Workbooks. Open (r "C: \ documents \ backlog raw data \ Metrics. The CSV", False)
XlBook=xlApp. Workbooks. Open (r "C: \ documents \ backlog raw data \ Metrics (1) the CSV", False)
XlBook=xlApp. Workbooks. Open (" C: \ documents \ Backlog - Python XLSM ", False)
XlBook. Application. The Run (" RawData automatically copy and paste ") # macro
XlBook. Application. The Run (" automatic screenshot ") # macro
XlBook. Application. The Run (screenshot of "Site") # macro
XlBook. Close (True)
XlApp. Quit ()
But because this needs to run once in a while, sometimes run out the background of excel will not shut down all success, influence the next run, always need to manually closing operation in the task manager, so want to ask if there are other ways to implement a process to ensure that the background of excel all were closed, the method of use without affecting the foreground of excel, thank you!
CodePudding user response:
They melody melody no one I they