PDA

View Full Version : Pass a variable to a built-in dialog



Ken Puls
04-23-2007, 01:25 PM
Hi guys,

I've never tried to do this, and haven't been able to find anything on the internet about it either.

I'm trying to hold a string for a password, and want to pass it to the Protect Sheet dialog box if I can. I know I can show the dialog with the following...

Dim dlg As Dialog
Set dlg = Application.Dialogs(xlDialogProtectDocument)

With dlg

.Show

End With

... but none of it's objects are exposed here. I'm curious if anyone has done this, or if it is possible. If not, I'll just build my own userform interface, but if I can avoid it, I'd rather.

Thanks,

vonpookie
04-23-2007, 01:39 PM
Do you mean like this?

Dim dlg As Dialog, pw As String
pw = "test"

Set dlg = Application.Dialogs(xlDialogProtectDocument)

With dlg
.Show , , pw
End With


I got the arguments from the help file ("Built-In Dialog Box Argument Lists"). The list for the ProtectDocument dialog is "contents, windows, password, objects, scenarios."

It just shows up in the dialog as the asterisks, but it seems to work.

Ken Puls
04-23-2007, 01:45 PM
<sigh> That's exactly what I meant, yes.

That's the problem with this stuff... it's trying to figure out how to ask the questions, y'know?

Thanks, VP. :)

Bob Phillips
04-23-2007, 02:15 PM
Ken, If you look at 'Built-In Dialog Box Argument Lists' in help all arguments re listed.

Ken Puls
04-23-2007, 02:18 PM
Yep, I see that. Like an idiot, though, I went hunting the object browser and Google for this one. (I'd been disappointed by the Help yesterday.)

Aussiebear
04-24-2007, 07:44 AM
Its nice to know that even the "good guys" seem to have an off day. :devil2:

Helps keep us "learners" sort of inspired.

Ken Puls
04-24-2007, 08:25 AM
?

Who's good? :dunno

tpoynton
04-24-2007, 09:26 AM
?

Who's good? :dunno

those who answer more questions than they ask?

Aussiebear
04-24-2007, 03:26 PM
:clap2::clap2::clap2: Well said.