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:
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.
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()
...