Is there a way to set the printer's properties using VBA?

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Is there a way to set the printer's properties using VBA?
:biggrin:
Sometimes we set the printer for BEST quality to do photos or brochures. Well if we don't change it back, when we go to print a spreadsheet, it takes forever because it is set on best quality. :biggrin:

So......
I want to be able to set the print properties to normal using VBA. :confused:
If this is impossible, please let me know that too.....
:(
Thank You,
Michael
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I'll be happy to learn otherwise but I'm not sure that you can. A kind of halfway house is to display the printer dialog then click the Properties button, like this:

Code:
Sub test()
Dim bResponse As Boolean
bResponse = Application.Dialogs(xlDialogPrinterSetup).Show
If bResponse = False Then
    MsgBox "User cancelled"
    Exit Sub
End If
' Rest of code here
End Sub
 
Upvote 0
VoG II,
I appreciate your input as always :biggrin: :biggrin:
I did find this:
Code:
Private Sub Worksheet_Activate()
     MsgBox "Horizontal Print Quality is " & _
    Worksheets("Sheet1").PageSetup.PrintQuality(1) & "  Horizontal Print Quality is " & _
    Worksheets("Sheet1").PageSetup.PrintQuality(2)
End Sub

Which this shows the Print Quality (vertical and Horizonal) in a message box.

I would like the ability to change the Best value (600) to the Normal value (300).

not sure how to get my code to do this.

I tried in a module:
Code:
Sub Macro1()
    With ActiveSheet
    .PageSetup.PrintQuality(1) = 300
    .PageSetup.PrintQuality(2) = 300
    End With
End Sub

It does not change it though.

Michael
 
Upvote 0
ideas?
I waited 2 days before bumping in hopes that someone may be able to help.

Michael
 
Upvote 0
Michael,

This appears to work in testing:
Code:
Sub TogglePrintQuality()
    With ActiveSheet.PageSetup
        .PrintQuality = IIf(.PrintQuality(1) = 600, 300, 600)
    End With
End Sub
 
Upvote 0
Greg,
Thank you for your code!
However, when testing it still prints Best. I am trying to get it to print Normal.

When I do it manually it works fine, but using code it just won't work??


Michael
 
Upvote 0
I just inserted a photo into a worksheet, printed it, ran that code and printed again -- one image good, one image not so purdy -- so it worked just fine for me. 'fraid I dunno what ta tell ya. Maybe set a watch on activesheet.pagesetup.printquality and step through TogglePrintQuality to see what's going on?
 
Upvote 0
let me ask you this. I put the code here:


Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
        .PrintQuality = IIf(.PrintQuality(1) = 600, 300, 600)
    End With
End Sub

Would this have any effect on this? Or do I need it in a worksheet, module or somewhere else.

I am not sure how to do what you are suggesting here?
Maybe set a watch on activesheet.pagesetup.printquality and step through TogglePrintQuality to see what's going on?

Thank you for your help though!! :)
Michael
 
Upvote 0
Michael,

My code was just to show "how to" and furthermore, it's a toggle. So putting it in the beforeprint() event handler is going to make it flip back and forth. Furthermore putting it in the event handler means you ALWAYS want to print at xxx dpi. Since you are trying to do this in code instead of just doing it by hand, I assume that there are times where you want code to print @ 300 dpi and times where you want your code to print @ 600 dpi. Otherwise just set by hand the one time and get on down da road, yes?

So all you should need is
Code:
ActiveSheet.PageSetup.PrintQuality = 300
or
Code:
ActiveSheet.PageSetup.PrintQuality = 600
at points in your code where you want to print at 300 dpi & 600 dpi respectively.
Regarding my prior advice -- have you never set a watch in the VBE?
  1. From the VBE menu Debug | Add Watch...
  2. Enter activesheet.pagesetup.printquality as the watch expression
  3. walk through the code using the F8 key
  4. one the expression initializes, it is collapsed (since it's an array), expand the array and continue to step (F8) through the code monitoring the values of the array elements to see what's going on.
 
Upvote 0

Forum statistics

Threads
1,216,767
Messages
6,132,599
Members
449,738
Latest member
brianm3y3r

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top