Macro to let user select printer.

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
710
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Morning Gang,
A little issue here.
I have two different reports here. One of witch is a label the other is a normal report. I am using Access 2000 and I want to be able to add a line to the script that will let the user select from the printer on the computer that they are using.I tried
Code:
Application.Dialogs(xlDialogPrinterSetup).Show
But does not work in Access 2k. Something similar to clicking File>Print>Select Printer>Print
Is there a way to get this to work in this version?
Thanks!
Pujo
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Is there a way to change the default printer to another printer, then back to the default printer?
Thanks,
Pujo
 
Upvote 0
Something like this to store the default and then change it:
Code:
Dim strDefaultPrinter As String
 
    ' get current default printer.
    strDefaultPrinter = Application.Printer.DeviceName
    Set Application.Printer = Application.Printers("Adobe PDF")

And then to set it back:
Code:
' Restore default printer
Set Application.Printer = Application.Printers(strDefaultPrinter)
 
Upvote 0
How would I incorporate your example into this script?
Code:
'Print Current Record Only
Private Sub Command82_Click()
On Error GoTo Err_Command82_Click

    Dim stDocName As String
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    stDocName = "Sample Label"
    DoCmd.OpenReport stDocName, acViewNormal, , "[Auto ID] = " & Me.[Auto ID]

Exit_Command82_Click:
    Exit Sub

Err_Command82_Click:
    MsgBox Err.Description
    Resume Exit_Command82_Click
    
End Sub
I can't seem to figure it out. Or even if I could get the print dialog up so that any user could select the printer of choice?
Thanks,
Pujo
 
Upvote 0
I may be on to something here.
I have searched the web and found a simple way for a user to select from dialog, but not liking the "Print Preview Method"
Here is what I have come up with.
Code:
Private Sub Command85_Click()
On Error GoTo Err_Command85_Click

    Dim stDocName As String
    stDocName = "Sample Label"
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.OpenReport stDocName, acViewPreview, , "[Auto ID] = " & Me.[Auto ID]
    DoCmd.RunCommand acCmdPrint

Exit_Command85_Click:
    Exit Sub

Err_Command85_Click:
    MsgBox Err.Description
    Resume Exit_Command85_Click
    
End Sub
Is there a way to disable the "acViewPreview" and get the same result? I tried to use "acViewNormal" but the report printed before I was able to select the printer. Can I get it to wait until a printer is selected?

Thanks,
Pujo
 
Upvote 0

Forum statistics

Threads
1,221,854
Messages
6,162,452
Members
451,765
Latest member
craigvan888

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