python - win32com -> powerpoint.application: skip password pop up dialogue

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



python - win32com -> powerpoint.application: skip password pop up dialogue



I have a lot of powerpoint file need to open. Some of the files require password, and I need to skip the pop up dialog. How can I skip this dialogue, and jump to the next path?



Example:



Example



I'm using win32com method to use powerpoint.application.



This is my code:


filename = 'test.pptx'
PPTApplication = win32com.client.Dispatch("PowerPoint.Application")
PPTApplication.DisplayAlerts = False
PPTApplication.Presentations.Open(filename,ReadOnly=True,WithWindow=False)



This is the function that I've checked:
https://msdn.microsoft.com/en-us/vba/powerpoint-vba/articles/presentations-open-method-powerpoint



DisplayAlert is set to False and ReadOnly is set to True, but the dialogue still pops up.




1 Answer
1



Solved,


import win32gui
import win32con
import win32com
import threading

flag = False
def terminate():
global flag
while (1):
hwnd = win32gui.FindWindow(None, 'Password')
if hwnd != 0:
win32gui.PostMessage(hwnd,win32con.WM_CLOSE,0,0)
break
if flag == True:
break

...
t = threading.Thread(target=terminate)
t.start()
try:
PPTApplication = win32com.client.Dispatch("PowerPoint.Application")
PPTApplication.Presentations.Open(filename,ReadOnly=True,WithWindow=False)
except:
t.join()
None

if t.is_alive():
flag = True
t.join()
...






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS