0

I am trying to convert multiple excels to pdfs. I want to get the first and the second worksheet from each file so I think one way is to hide the other worksheets, but I can't find how.

Could you please help me?

Below is the code that converts excels to pdfs.

import glob
from win32com.client import DispatchEx
path='/folder_path'
filenames=glob.glob(path +"/*xlsx")

for i in filenames:

  pdf_path = i.replace('xlsx', 'pdf')
  xlApp = DispatchEx("Excel.Application")
  books = xlApp.Workbooks.Open(i)
  books.ExportAsFixedFormat(0,pdf_path)
  xlApp.Quit()

Thanks in advance

Tsorts
  • 31
  • 3

0 Answers0