title: How to open the excel file to take screen shot of the file and close the file which is opened using python
body: <p>#I used this to open an excel file</p>
  <p>os.startfile(&quot;filepath&quot;)</p>
  <p>sleep(10)</p>
  <p>#Screenshot</p>
  <p>ss=pyautogui.screenshot()</p>
  <p>ss.save(&quot;savepath&quot;)</p>
  <p>#close the excel file</p>
  <p>os.system(&quot;taskkill /im EXCEL.exe&quot;)</p>
  <p>Here taskkill is killing the excel file which are already in use but i want to close the particular excelfile to close.</p>
  <p>And i used wait time to take the screenshot of excel. Can i have a better solution.</p>
  <ol>
  <li>To open excel</li>
  <li>Take screenshot of the excel</li>
  <li>Close the excel file</li>
  </ol>