opening password protected PPT2002 file in VB

  • Thread starter Thread starter Nitin
  • Start date Start date
N

Nitin

i am writting code to convert ppt2gif in isualBasic......i
want to open ppt file by this command....
Set pre = ppt.Presentations.Open(filename:=c:\xyz)

but powerpoint 2002 has password also......to get some
function of this kind
Set pre = ppt.Presentations.Open(filename:=c:\xyz,
password="abcd")
, what should i do ,. do i need to install new version of
VBA or new version of VB ie VB.NET.

Thanks
Nitin
 
Nitin,
You can use this snippet which makes use of SendKeys.
There is no VBA method open a presentation protected with a password in
PowerPoint XP nor is there a way to determine if the presentation is
password protected. However, if you know the password to a presentation,
then you can try the following workaround if it suits you.

1. Open the main presentation and switch to Visual Basic Editor (Alt + F11)
2. Insert a code module into the VBA project.
3. Copy and paste the following snippet.
' ----------snippet -------
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 oPres As Presentation
TimerID = SetTimer(0, 0, 2000, AddressOf PassProc)
' Replace with your password
sPwd = "shyam"
' Replace E:\PresPass.ppt with your path to presentation
Call Presentations.Open("E:\prespass.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
' --------End of Snippet ----
4. Run the macro - OpenPassPres.

You will notice the Password window momentarily and then the password will
be transmitted and the presentation will open.

--
Regards
Shyam Pillai

Handout Wizard
http://www.mvps.org/skp/how/
 
Thanks Mr Shyam and Steve

My java program is calling a process which opnes a
powerpoint file(to convert it into GIF)....So how can run
this macro before opening any powerpoint presentation ?

Thanks
Nitin
 
I was trying to do this but could not...Whenever ppt file
is opened this macro should run automatically , if file is
password protected, macro should close powerpoint
application say in 10 seconds....is it possible to do
that ?

Thanks
Nitin
 
Back
Top