I am trying to convert ptx to pdf using "Presentation.SaveAs (path_file, 32)". It does not work. Throws error "pywintypes.com_error: (-2147352567, 'Error.', (0, 'Microsoft PowerPoint 2016', 'Presentation.SaveAs: PowerPoint cannot save ^ 0 to ^ 1.', '', 0, -2147467259) , None) ". With other formats, everything works. For example, I specify 1 instead of 32, it saves.
import win32com.client
import sys
import os
wrk_dir = 'd:/Python/ppt_to_pdf/'
os.chdir(wrk_dir)
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True
for root, dirs, files in os.walk(wrk_dir):
for file in files:
if file.endswith(".pptx"):
path_file = os.path.join(root, file)
os.rename(path_file, path_file.replace(' ', '_'))
path_file = path_file.replace(' ', '_')
Presentation = Application.Presentations.Open(path_file)
path_file = path_file.replace('.pptx','.pdf')
Presentation.SaveAs(path_file, 32)
Presentation.Close()