Link to home
Start Free TrialLog in
Avatar of BrianBeck
BrianBeck

asked on

Getting dlgCommonDialog to work

Hi Experts

I've added a CommonDialog control to my Form1, and in that form's code I've included:

Private Sub mnuFile_PageSetup_Click()
   With dlgCommonDialog
        .CancelError = True
        .DialogTitle = "Page Setup"
        .Flags = cdlPDPrintSetup
        .ShowPrinter
    End With
End Sub

I run the app and VB stops at the dlgCommonDialog line and brings up a "variable not defined" message.
Why is this and how do I fix it?

Thanks in advance
Brian
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Select Microsoft common dialog control 6.0 from Projects->components

Add the common dialog control to your form and rename dlgCommonDialog
did you set the name of the commonDialog to "dlgCommonDialog"? check it.

if it is named properly then is the menu is in the same form?( what i guess is may be menu is on MDI form and commondialog on mdi child. if this is the case add form name before dlgCommonDialog somthing like form1.dlgCommonDialog)
Avatar of BrianBeck
BrianBeck

ASKER

Thanks EDDYKT,

Yes I've done step 1 and added the control to my form.
But how do I rename the control??  If I right-click the control, I can call up its Property page, but there doesnt seem to be a Rename function...

I'm sure there's a simple answer...much appreciated.
select the control.

press function key F4

you will get one properties window. in that window the first property (name) there you set the name.
ASKER CERTIFIED SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Private const cdlPDPrintSetup = &H40

Also maybe add this
Open the properties page window. Click on the common dialog control
In the properties page window doubl click Name , Change the Commondialog1 to dlgConnonDialog