If manipulate means populate some of those fields when you're protecting the
sheet:
Option Explicit
Sub testme2()
Dim wkbk As Workbook
Set wkbk = ActiveWorkbook
If wkbk.ProtectWindows _
Or wkbk.ProtectStructure Then
'do nothing
Else
On Error Resume Next
Application.Dialogs(xlDialogWorkbookProtect).Show True, False, "aa"
On Error GoTo 0
If wkbk.ProtectWindows _
Or wkbk.ProtectStructure Then
'do nothing
Else
MsgBox "still unprotected"
End If
End If
End Sub
The parms for xlDialogWorkbookProtect are in this order:
structure, windows, password
If you click on dialogs and hit f1, you can use that to see all the dialogs and
all their parms. (after a few clicks.)
"T-容x" wrote:
>
> not really what i'm looking for but you gave me an idea....
> one more thing... is there a way to manipulate the Workbook protect
> dialog?
> i haven't used Application.Dialogs before....
>
> Thanks a lot!!!
>
> Dave Peterson Wrote:
> > Maybe you can just show that dialog and react afterwards:
> >
> > Option Explicit
> > Sub testme()
> >
> > Dim wkbk As Workbook
> > Set wkbk = ActiveWorkbook
> >
> > If wkbk.ProtectWindows _
> > Or wkbk.ProtectStructure Then
> > On Error Resume Next
> > Application.Dialogs(xlDialogWorkbookProtect).Show
> > On Error GoTo 0
> >
> > If wkbk.ProtectWindows _
> > Or wkbk.ProtectStructure Then
> > MsgBox "still protected"
> > End If
> > End If
> >
> > End Sub
> >
> >
> >
> > "T-容x" wrote:
> > >
> > > well, yeah... initially, i do know the password (i set it).
> > > unfortunately, my workbook also has a 'Protect/Unprotect Workbook'
> > menu
> > > item so that users can unprotect/protect the workbook w/out having
> > to
> > > know and specify the password. (i did this in case users really need
> > to
> > > make changes not accessible through the custom menu i provided.)
> > Problem
> > > is, while the book is unprotected, users might protect it again
> > using
> > > the buit-in 'Protect Workbook...' in the 'Tools|Protection' menu and
> > > specify a different password. If this happens, my code will crash
> > > because, then, the new password will not equal the hard-coded
> > password.
> > > I'd like that, if possible, i'd not have to hard-code a password and
> > > just query the workbook for it.
> > >
> > > MyWorkbook.Unprotect QueriedPassword
> > > 'changes here... delete sheet, rename, insert, etc...
> > > MyWorkbook.Protect QueriedPassword, True
> > >
> > > Thanks anywayz... i'll probably just have to find a different
> > > approach...
> > > Thanks!!!
> > >
> > > Dave Peterson Wrote:
> > > > You could use inputbox to ask for the password and if it matches
> > the
> > > > password
> > > > (you should know it), then continue.
> > > >
> > > > "T-容x" wrote:
> > > > >
> > > > > Hi! Is it possible to access in VBA a "readable" version of the
> > > > workbook
> > > > > protection password? I tried using the Password property of the
> > > > Workbook
> > > > > object but it just returns a string of asterisks.
> > > > >
> > > > > I have an excel workbook (w/ VBA code). The workbook is password
> > > > > protected so users don't accidentally delete sheets, change
> > sheet
> > > > > names, insert new sheets, etc... I allow the users to do these
> > > > through
> > > > > a dynamically created menu. So, their actions are controlled.
> > > > >
> > > > > In order to do the changes, I use the ff code:
> > > > >
> > > > > MyWorkbook.Unprotect ThePassword
> > > > > 'changes here... delete sheet, rename, insert, etc...
> > > > > MyWorkbook.Protect ThePassword, True
> > > > >
> > > > > I would like the user (admin for the particular excel file) to
> > be
> > > > able
> > > > > to specify the password...
> > > > >
> > > > > --
> > > > > T-容x
> > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > T-容x's Profile:
> > > > http://www.excelforum.com/member.php...o&userid=26572
> > > > > View this thread:
> > > > http://www.excelforum.com/showthread...hreadid=398493
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > >
> > > --
> > > T-容x
> > >
> > ------------------------------------------------------------------------
> > > T-容x's Profile:
> > http://www.excelforum.com/member.php...o&userid=26572
> > > View this thread:
> > http://www.excelforum.com/showthread...hreadid=398493
> >
> > --
> >
> > Dave Peterson
>
> --
> T-容x
> ------------------------------------------------------------------------
> T-容x's Profile: http://www.excelforum.com/member.php...o&userid=26572
> View this thread: http://www.excelforum.com/showthread...hreadid=398493
--
Dave Peterson
Bookmarks