Solved

Changing printer settings

Posted on 2000-03-13
6
165 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no 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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now