Solved

Changing printer settings

Posted on 2000-03-13
6
169 Views
Last Modified: 2010-05-02
Using 'form1.print' I can print the contents of a form. How do I show the user the printer dialog box so that they can select a printer and change the print options?
0
Comment
Question by:mi5
  • 4
6 Comments
 
LVL 1

Accepted Solution

by:
fbtcell earned 25 total points
ID: 2611534
On your form create a CommonDialog (ex : MyDiag), and put the following code in your form (for the btPrinterSetUp button for example) :

Private Sub btPrinterSetUp_Click()
diagSys.ShowPrinter
End Sub

diagSys.ShowPrinter will call for you the setup printer dialog.
0
 
LVL 1

Expert Comment

by:MitchBroadhead
ID: 2611547
remember to use the cancel error:

on error resume next
diagsys.CancelError = true
diagsys.caption = "Print something"
diagsys.showprinter

if err = 0 then
    Printfile(diagsys.Filename)
else
    'Cancel button was pressed
endif
 
0
 
LVL 1

Expert Comment

by:MitchBroadhead
ID: 2611550
Oh yeah

the printewr dialog just sets printer = to the printer in question

so just use printer.print
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mi5
ID: 2611566
How do I use this dialog to change the printer settings and print the contents of my form on the selected printer?
0
 
LVL 1

Expert Comment

by:MitchBroadhead
ID: 2611608
form1.PrintForm

The printer should have already been selected by the print dialog box (otherwise the cancel error would have been raised)
0
 
LVL 1

Expert Comment

by:MitchBroadhead
ID: 2611612
The final code should look like this:

sub cmdPrintForm_Click()

on error resume next

diagsys.CancelError = true
diagsys.caption = "Print something"
diagsys.showprinter

if err = 0 then
    form1.PrintForm
else
    'Cancel button was pressed
endif

end sub
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question