Opening password protected PPT in VB

D

djerinic

I woud like to open password protected PPT from vb6. I found code (see
below) that run in PPT (code is saved as macro and I started macro),
but doesn't work if I place it in VB module. Can anybody help me!

Thanks, Dak


Code:

Option Explicit
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal
nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As
Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal
nIDEvent As Long) As Long
Public TimerID As Long
Public sPwd As String

Sub OpenPassPres()
Dim objPPT As PowerPoint.Application
Dim objPres As PowerPoint.Presentation
Set objPPT = New PowerPoint.Application
objPPT.Visible = msoTrue

TimerID = SetTimer(0, 0, 2000, AddressOf PassProc)
' Replace with your password
sPwd = "q"
' Replace C:\Test.ppt with your path to presentation
Call Presentations.Open("C:\Test.ppt")
End Sub

Sub PassProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)
TimerID = KillTimer(0, TimerID)
SendKeys sPwd & "~"
End Sub
 
S

Shyam Pillai

The code was designed to run in the PPT environment and not from VB.
Sendkeys is sent to the active window. So you will need to ensure that the
password dialog is the window in the foreground when sendkeys is sent. A
more reliable approach will be to get the handle of the Password window
textbox and use SendMessage to send the password to it.


--
Regards,
Shyam Pillai

Toolbox
http://skp.mvps.org/toolbox
 
D

dak

Hi,

This is usefull information. But I am new in Windows API so I don't now
how to get the handle of the Password window textbox and how to use
SendMessage. Can you write me code for this (what I have to change in
my code) or send me any usefull link about this.

Thanks,

Dak

Shyam Pillai je napisao:
 
Joined
Nov 5, 2025
Messages
16
Reaction score
0
Recently, I was having trouble since one of my crucial PowerPoint files was password-protected. I tried a few different approaches before discovering the Softaken PowerPoint Password Remover Tool, and to be honest, it worked rather well. Even those without technical expertise can use the program thanks to its extremely user-friendly design. After I added my PowerPoint file, the protection was lifted in a matter of minutes. The data in my file was totally secure, which is the finest part. I would strongly advise anyone who is having problems opening a password-protected PowerPoint file to try this program, especially if the file is yours or you have authorization to access it.
 
Top