0

I want to write a python script that can take a screenshot of an excel file located at:

/Users/Desktop/Automation/file.xlsm

Right now I'm using pyscreenshot and doing it in the following way:

import pyscreenshot as ImageGrab
import os

im=ImageGrab.grab()
im.show()

ImageGrab.grab_to_file('/im.png')

But this takes the screenshot of the current open screen. I, instead want a screenshot of a particular file. How do I do it?

Reshma
  • 21
  • 1
  • 4
  • 4
    To use any screen capture code, whatever you want to capture has to be **on the screen**. That by definition means that the file has to be open and visible, if you apply a little common sense. How would you expect **screeshot** to capture something **not on the screen but in a file on disk**? – Ken White Mar 28 '17 at 00:22
  • 1
    Try first opening the file with [`os.system()`](https://docs.python.org/3/library/os.html#os.system), and then use the screenshot module. It will grab whatever is shown when the associated application displays when if first opens the file (which may not be the whole thing). – martineau Mar 28 '17 at 00:34

0 Answers0