title: Use python extract images from Excel sheets
body: <p>I found some Python2 code to extract images from Excel files.</p>
  
  <p>I have a very fundamental question: Where shall I specify <strong>the path</strong> of my target excel file?</p>
  
  <p>Or does it only work with an active opened Excel file?</p>
  
  <pre><code>import win32com.client       # Need pywin32 from pip
  from PIL import ImageGrab    # Need PIL as well
  import os
  
  excel = win32com.client.Dispatch("Excel.Application")
  workbook = excel.ActiveWorkbook
  
  wb_folder = workbook.Path
  wb_name = workbook.Name
  wb_path = os.path.join(wb_folder, wb_name)
  
  #print "Extracting images from %s" % wb_path
  print("Extracting images from", wb_path)
  
  image_no = 0
  
  for sheet in workbook.Worksheets:
      for n, shape in enumerate(sheet.Shapes):
          if shape.Name.startswith("Picture"):
              # Some debug output for console
              image_no += 1
              print("---- Image No. %07i ----", image_no)
  
              # Sequence number the pictures, if there's more than one
              num = "" if n == 0 else "_%03i" % n
  
              filename = sheet.Name + num + ".jpg"
              file_path = os.path.join (wb_folder, filename)
  
              #print "Saving as %s" % file_path    # Debug output
              print('Saving as ', file_path)
  
              shape.Copy() # Copies from Excel to Windows clipboard
  
              # Use PIL (python imaging library) to save from Windows clipboard
              # to a file
              image = ImageGrab.grabclipboard()
              image.save(file_path,'jpeg')
  </code></pre>