Solved

Changing printer settings

Posted on 2000-03-13
6
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 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