CommonDialog - ShowPrinter

CommonDialog - ShowPrinter

Anonymous
Not applicable
598 Views
6 Replies
Message 1 of 7

CommonDialog - ShowPrinter

Anonymous
Not applicable
Does enyone know why "Page Setup" dialog does not return the right PaperSize
and the Orientation that user changes. Here is the code:

Private Sub Command1_Click()

On Error Resume Next

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

With CommonDialog1
.CancelError = True
.Flags = cdlPDNoSelection + _
cdlPDPageNums + _
cdlPDDisablePrintToFile + _
cdlPDPrintSetup ' + _
cdlPDNoWarning
.ShowPrinter

If Err Then
If Err.Number = 32755 Then
Exit Sub
Else
MsgBox Err.Number & " : " & Err.Description
End If
End If
End With

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

End Sub
0 Likes
599 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
What error/behavior exactly are you getting? As far as i know, you can't use
the CommonDialog control in vba apps....

-Chris

"MadCAD" wrote in message
news:5018123@discussion.autodesk.com...
Does enyone know why "Page Setup" dialog does not return the right PaperSize
and the Orientation that user changes. Here is the code:

Private Sub Command1_Click()

On Error Resume Next

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

With CommonDialog1
.CancelError = True
.Flags = cdlPDNoSelection + _
cdlPDPageNums + _
cdlPDDisablePrintToFile + _
cdlPDPrintSetup ' + _
cdlPDNoWarning
.ShowPrinter

If Err Then
If Err.Number = 32755 Then
Exit Sub
Else
MsgBox Err.Number & " : " & Err.Description
End If
End If
End With

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

End Sub
0 Likes
Message 3 of 7

Anonymous
Not applicable
I'm using it in a VB application. There is NO specific error message.



To check what I'm talking about, run a new vb project, add MS Common Dialog
ActiveX reference to your project and add one CommonDialog1 control to the
project. Add one command button too. Copy and paste the code I had on my 1st
post. Run the project and click the command button. Pay attention to the 1st
message. Then made some changes on the printer dialog box; say, change the
printer, the paper and the layout options. Accept it. Now compare your 1st
and the current message. Paper and orientation options did not take changes.
This is what I'm talking about.

This weekend, I found that all MSDN documentations, plus most web vb
"advisers" suggest that this is a driver related issue, but I never seen
this control worked since I'm programming w/ vb (1997), in all systems I
used to work. I have one word for this control: useless, if not bal..it. The
solution I see is in direct device contexts access.


"Chris Shoemaker" wrote in message
news:5019094@discussion.autodesk.com...
What error/behavior exactly are you getting? As far as i know, you can't use
the CommonDialog control in vba apps....

-Chris

"MadCAD" wrote in message
news:5018123@discussion.autodesk.com...
Does enyone know why "Page Setup" dialog does not return the right PaperSize
and the Orientation that user changes. Here is the code:

Private Sub Command1_Click()

On Error Resume Next

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

With CommonDialog1
.CancelError = True
.Flags = cdlPDNoSelection + _
cdlPDPageNums + _
cdlPDDisablePrintToFile + _
cdlPDPrintSetup ' + _
cdlPDNoWarning
.ShowPrinter

If Err Then
If Err.Number = 32755 Then
Exit Sub
Else
MsgBox Err.Number & " : " & Err.Description
End If
End If
End With

With Printer
MsgBox "DeviceName:" & vbTab & .DeviceName & vbLf & _
"PaperSize:" & vbTab & .PaperSize & vbLf & _
"Orientation:" & vbTab & .Orientation
End With

End Sub
0 Likes
Message 4 of 7

Anonymous
Not applicable
As you are probably aware, the commondialog control doesn't have a .PaperSize and a
.PaperSource property but it does have an .Orientation property. So, at least, you should
be able to set the printer's orientation thus:

With CommonDialog1
....
.ShowPrinter
Printer.Orientation = .Orientation
...
0 Likes
Message 5 of 7

GTVic
Advisor
Advisor
At first I didn't think your method was possible but try looking here:

http://www.vbwm.com/forums/topic.asp?TOPIC_ID=4006
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B322710
0 Likes
Message 6 of 7

Anonymous
Not applicable
Also,
CommonDialog only can change the printer name (the printer object) but
nothing more, although there are many options come with offered dialog boxes
(print, page setup).


"Allen Johnson" wrote in message
news:5019302@discussion.autodesk.com...
As you are probably aware, the commondialog control doesn't have a
.PaperSize and a
.PaperSource property but it does have an .Orientation property. So, at
least, you should
be able to set the printer's orientation thus:

With CommonDialog1
....
.ShowPrinter
Printer.Orientation = .Orientation
...
0 Likes
Message 7 of 7

Anonymous
Not applicable
Here is the controdictary featurtures w/ CommonDialog:

From a user point of view the printer may be configured for a particular
application with its
Name, PaperSize, Orientation, Colored/Grayscale print, Tray/Outotray
options.

Now look how CommonDialog works
1. Directly changes the printer
2. Returns orientatioin value

Very poor performance.



"MadCAD" wrote in message
news:5019578@discussion.autodesk.com...
Also,
CommonDialog only can change the printer name (the printer object) but
nothing more, although there are many options come with offered dialog boxes
(print, page setup).


"Allen Johnson" wrote in message
news:5019302@discussion.autodesk.com...
As you are probably aware, the commondialog control doesn't have a
.PaperSize and a
.PaperSource property but it does have an .Orientation property. So, at
least, you should
be able to set the printer's orientation thus:

With CommonDialog1
....
.ShowPrinter
Printer.Orientation = .Orientation
...
0 Likes