file share settings password

  • Thread starter Thread starter CG
  • Start date Start date
C

CG

I have a macro that copies a presentation to a new file based on a different
template. When a file that has a file share settings password
(Options-Security-file share settings for this document) the file is opened
as read only and can not be saved. Is there any flag that can be checked so
I can notify the user the file can not be copied? Or is there a way to trap
and error to tell if the file can not be saved.

I would prefer to be able to copy the file someway however assume that can
not be done without the password.
 
I have a macro that copies a presentation to a new file based on a different
template. When a file that has a file share settings password
(Options-Security-file share settings for this document) the file is opened
as read only and can not be saved. Is there any flag that can be checked so
I can notify the user the file can not be copied? Or is there a way to trap
and error to tell if the file can not be saved.

I would prefer to be able to copy the file someway however assume that can
not be done without the password.

To expand on John's suggestion a bit, the problem you'll have is that when your
code tries to open a password protected file, PPT will show a dialog box asking
the user to enter the password, cancel or open as read-only.

If you're willing to let the user see that and deal with it, then something
like this should help:

Sub SideSteppingAnotherPPTNuisance()

On Error GoTo ErrorHandler

Dim oPres As Presentation

' try to open the presentation
Set oPres = Presentations.Open("c:\temp\readonly.ppt")

' if the user clicked Open as Read Only, you can trap that thus,
' per John's suggestion:
If oPres.ReadOnly Then
MsgBox "Houston, we have a Read-Only file"
Else
' User suppplied a password or it's not
' a passworded file
MsgBox "All operations nominal, proceed w/ countdown"

End If

NormalExit:
Exit Sub

ErrorHandler:
MsgBox "User clicked CANCEL"
End Sub
 
Steve Rindsberg said:
To expand on John's suggestion a bit, the problem you'll have is that when your
code tries to open a password protected file, PPT will show a dialog box asking
the user to enter the password, cancel or open as read-only.

If you're willing to let the user see that and deal with it, then something
like this should help:

Sub SideSteppingAnotherPPTNuisance()

On Error GoTo ErrorHandler

Dim oPres As Presentation

' try to open the presentation
Set oPres = Presentations.Open("c:\temp\readonly.ppt")

' if the user clicked Open as Read Only, you can trap that thus,
' per John's suggestion:
If oPres.ReadOnly Then
MsgBox "Houston, we have a Read-Only file"
Else
' User suppplied a password or it's not
' a passworded file
MsgBox "All operations nominal, proceed w/ countdown"

End If

NormalExit:
Exit Sub

ErrorHandler:
MsgBox "User clicked CANCEL"
End Sub



-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Steve and John,

Thanks for the response!

However I did not make the issue completely clear. I run the macro after i
have opened a password protected file and selecting Read Only. The real
issue is on these files I can not copy the slides without an error and the
file can not be saved with Saveas (it is greyed out) with out an error.
Since a non-password protected file opened as Read only can be copied and
saved using SaveAs, I do not believe the read only flag useful in this
situation. It would be great if there was a saveas flag.

Maybe to add more clarity, I want to copy and save normal (not password
protected) Read Only files. I want to figure out how to identify a password
protected file that has been opened Read Only so I can tell the user the file
can not be copied and saved.


Thanks for any help!
 
However I did not make the issue completely clear. I run the macro after i
have opened a password protected file and selecting Read Only. The real
issue is on these files I can not copy the slides without an error and the
file can not be saved with Saveas (it is greyed out) with out an error.
Since a non-password protected file opened as Read only can be copied and
saved using SaveAs, I do not believe the read only flag useful in this
situation. It would be great if there was a saveas flag.

Maybe to add more clarity, I want to copy and save normal (not password
protected) Read Only files. I want to figure out how to identify a password
protected file that has been opened Read Only so I can tell the user the file
can not be copied and saved.

Ah. Try to save it and trap any errors that occur:

Sub SaveSafely()

On Error GoTo ErrorHandler

Call ActivePresentation.SaveAs("C:\temp\saved.ppt", ppSaveAsDefault)
MsgBox "Saved it ok"

NormalExit:
Exit Sub
ErrorHandler:
MsgBox "We seem to have entered a no-fly zone"
Resume NormalExit
End Sub
 
--
CG


Steve Rindsberg said:
Ah. Try to save it and trap any errors that occur:

Sub SaveSafely()

On Error GoTo ErrorHandler

Call ActivePresentation.SaveAs("C:\temp\saved.ppt", ppSaveAsDefault)
MsgBox "Saved it ok"

NormalExit:
Exit Sub
ErrorHandler:
MsgBox "We seem to have entered a no-fly zone"
Resume NormalExit
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
Steve Rindsberg said:
??

Must not have used enough glue on da message. It fell right off.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


Steve,

Hopefully the glue will stick this time. I did have a problem submitting
it, I should have checked.

Thanks for your help once again. Indirectly you answered my question.
Instead of trapping the error on the saveas I trapped the error on the slide
copy. I did not have a need to save the file until after I copied the slides
to the new presentation. One of these days I will get comfortable with
trapping error like this. I am always looking for flag to check and try to
avoid the errors.

Again, Thanks for you help!
 
Hopefully the glue will stick this time. I did have a problem submitting
it, I should have checked.

StickyStickySticky ... good glue. said:
Thanks for your help once again. Indirectly you answered my question.
Instead of trapping the error on the saveas I trapped the error on the slide
copy. I did not have a need to save the file until after I copied the slides
to the new presentation. One of these days I will get comfortable with
trapping error like this. I am always looking for flag to check and try to
avoid the errors.

Again, Thanks for you help!

Glad you got it sorted out. It does seem a little ... I dunno ... risky to just
let errors occur, even if you are trapping them, so I understand what you're
saying. But so far I've never seen any evidence that trapped errors (if the
trapping code recovers nicely) cause any harm in and of themselves.
 
Back
Top