As you can see:
TypeError: Open() got an unexpected keyword argument 'Password'
The error clearly outlines that Presentations.Open() method doesn’t have a Password parameter. Thus, passing it raises the TypeError
To programmatically open the password-protected pptx file, you can use msoffcrypto-tool
pip install msoffcrypto-tool
It decrypts the file to a temp copy first, then opens the decrypted copy via the COM object.
Here's an example:
import msoffcrypto import tempfile import win32com.client as win32 file_path = r"your pptx file path" password = "your password" # decrypt to a temp file with open(file_path, "rb") as f: office = msoffcrypto.OfficeFile(f) office.load_key(password=password) with tempfile.NamedTemporaryFile(delete=False, suffix=".pptx") as out: office.decrypt(out) decrypted_path = out.name # open the decrypted copy ppt = win32.Dispatch("PowerPoint.Application") ppt.Visible = True pres = ppt.Presentations.Open(decrypted_path, ReadOnly=True, WithWindow=True)
output:
If the provided password is correct, it'll open the file .
otherwise, if the password is incorrect, it'll throw InvalidKeyError
msoffcrypto.exceptions.InvalidKeyError: The file could not be decrypted with this password
reference
Password="123"(which isn't a supported option) and you'll be prompted for the password.