Skip to main content
This forum is closed to new posts and responses. The content has been migrated to the Digital Solutions Community. Please join us there for new content as well as this content. For customer support, please visit the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Get and set default printer

I used this code few years ago, so I do not remember exactly how it worked, but you can get and set the default printer with it.
In the form declaration I used this (maybe you do not need everything):

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
Dim WshNetwork As Variant
Dim WshPrinters As Variant
Dim pArray() As String
Dim strBuffer As String * 254
Dim iRetValue As Long
Dim DefaultPrinter As String
Dim pCount As Integer
Dim n As Integer
Dim PrinterPath As Variant

And I had a button with this sub:

Sub Printer
' Retreive current default printer information
iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
DefaultPrinter$ = Left(strBuffer, Instr(strBuffer, ",") - 1)
Print "Current default printer is " & DefaultPrinter$

Set WshNetwork = CreateObject("WScript.Network")
Set WshPrinters = WshNetwork.EnumPrinterConnections()

'count the connected printers
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then pCount%=pCount%+1
Next
'collect the names of the connected printers
Redim pArray(pCount%-1) As String
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then
pArray(pCount%) = wshPrinters(n)
pCount%=pCount%+1
End If
Next

PrinterPath = ws.Prompt(4,"Printer selection","Please select the printer:","",pArray)

If Cstr(PrinterPath)="" Then Exit Sub

WshNetwork.SetDefaultPrinter Cstr(PrinterPath)

Print "Default printer is now " & Cstr(PrinterPath)

app.ActiveWorkbook.PrintOut

WshNetwork.SetDefaultPrinter DefaultPrinter$
Print "Default printer restored to " & DefaultPrinter$

Set WshNetwork = Nothing
Set WshPrinters = Nothing
End Sub

I hope you can use it.


Feedback response number WEBB8NFQ2W created by ~August Fezkisterflar on 11/09/2011

get default printer name (~Lisa Fezjumiso... 3.Nov.11)
. . Link to an FAQ and a request (~Martha Lopjipy... 3.Nov.11)
. . Try this... (~Kim Quetnulyle... 4.Nov.11)
. . . . Any way to set the default printer?... (~Martha Lopjipy... 7.Nov.11)
. . . . . . This is what I do... (~Kim Quetnulyle... 7.Nov.11)
. . . . . . . . Sweet but... (~Martha Lopjipy... 8.Nov.11)
. . You can find it in the windows regi... (~Fritz Ekfoober... 3.Nov.11)
. . . . get default printer name (~Lisa Fezjumiso... 3.Nov.11)
. . . . . . In Domino Designer help just search... (~Fritz Ekfoober... 3.Nov.11)
. . . . . . . . RE: get default printer name (~Lisa Fezjumiso... 8.Nov.11)
. . . . . . . . . . Get and set default printer (~August Fezkist... 9.Nov.11)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS