Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / September 2006

Tip: Looking for answers? Try searching our database.

Opening password protected PPT in VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
djerinic@gmail.com - 21 Sep 2006 09:11 GMT
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
Shyam Pillai - 21 Sep 2006 13:28 GMT
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.

Signature

Regards,
Shyam Pillai

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

>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),
[quoted text clipped - 33 lines]
> SendKeys sPwd & "~"
> End Sub
dak - 22 Sep 2006 08:08 GMT
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:
> 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
[quoted text clipped - 46 lines]
> > SendKeys sPwd & "~"
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.