Results 1 to 2 of 2

Set report print default to BW by User

  1. #1
    sherrimca is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2016
    Posts
    1

    Set report print default to BW by User


    Two users are printing to a Canon iR-ADV C5240; this is a color printer, however we want the default print jobs for these two users to print in black & white. I know they can change properties when they print, however when printing specific pages from hundreds of pages, it is frustrating to change to BW every single time a page is found to print. There must be a way to default a report to BW, changing to color only when necessary.

    Sherri

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    5,055
    make a table that has the printer names, then user picks from combo, clicks SET DFLT button , which runs this code

    button click code:
    Code:
    sub btnSetPrinter_click()
         call SetDefaultPrinter(cboBox)
    end sub
    put THIS code in a module
    Code:
    Private Const HWND_BROADCAST As Long = &HFFFF&
    Private Const WM_WININICHANGE As Long = &H1A
    
    ' The following code allows one to read, and write to the WIN.INI files
    ' In win 2000 the printer settings are actually in the registry. However, windows
    ' handles this correctly
    '
    Private Declare Function GetProfileString Lib "kernel32" _
       Alias "GetProfileStringA" _
      (ByVal lpAppName As String, _
       ByVal lpKeyName As String, _
       ByVal lpDefault As String, _
       ByVal lpReturnedString As String, _
       ByVal nSize As Long) As Long
    
    Private Declare Function WriteProfileString Lib "kernel32" _
       Alias "WriteProfileStringA" _
      (ByVal lpszSection As String, _
       ByVal lpszKeyName As String, _
       ByVal lpszString As String) As Long
    
    Private Declare Function SendMessage Lib "user32" _
       Alias "SendMessageA" _
      (ByVal hwnd As Long, _
       ByVal wMsg As Long, _
       ByVal wParam As Long, _
       lparam As Any) As Long
    
    
    
    Function SetDefaultPrinter(strPrinterName As String) As Boolean
    
       Dim strDeviceLine As String
       Dim strBuffer     As String
       Dim lngbuf        As Long
        
      ' get the full device string
      '
       strBuffer = Space(1024)
       lngbuf = GetProfileString("PrinterPorts", strPrinterName, "", strBuffer, Len(strBuffer))
      
      'Write out this new printer information in
      ' WIN.INI file for DEVICE item
      If lngbuf > 0 Then
         
         strDeviceLine = strPrinterName & "," & _
                         fstrDField(strBuffer, Chr(0), 1) & "," & _
                         fstrDField(strBuffer, Chr(0), 2)
                         
         Call WriteProfileString("windows", "Device", strDeviceLine)
         SetDefaultPrinter = True
         
         ' Below is optional, and should be done. It updates the existing windows
         ' so the "default" printer icon changes. If you don't do the below..then
         ' you will often see more than one printer as the default! The reason *not*
         ' to do the SendMessage is that many open applications will now sense the change
         ' in printer. I vote to leave it in..but your case you might not want this.
         '
         
         'Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, ByVal "windows")
        
      Else
         SetDefaultPrinter = False
      End If
           
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2015, 02:26 PM
  2. Replies: 1
    Last Post: 02-21-2015, 10:35 PM
  3. Replies: 19
    Last Post: 04-02-2014, 02:53 PM
  4. Print to Default Printer
    By bsc0617 in forum Access
    Replies: 7
    Last Post: 10-10-2013, 06:46 AM
  5. Replies: 3
    Last Post: 03-11-2013, 04:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums