how to choose a printer

  • Thread starter Thread starter saymard
  • Start date Start date
S

saymard

Hi every body

I'm looking for a way to be able to choose a specific printer and to set
the margins of the report. Is it possible with the vba code ? Does some
body know how ?

Thanks for your help
 
If you are using Access XP or above you can use the Printers collection to
choose a specific printer.

If this is not your case, you can write this function in a standard module
(it retrieves the names of the printers)

Public Function wshPrinters() As Collection
Dim wshNetwork As Object 'New wshNetwork
Dim col As New Collection
Dim i As Integer

Set wshNetwork = CreateObject("WScript.Network")

With wshNetwork.EnumPrinterConnections
For i = 0 To .Count - 1
If i Mod 2 <> 0 Then
col.Add .Item(i)
End If
Next
End With

Set wshPrinters = col

Set col = Nothing
Set wshNetwork = Nothing

End Function

and you can call it in this way

Sub EnumPrinters()
Dim prn As Variant

For Each prn In wshPrinters
Debug.Print prn
Next

End Sub

For setting the report's margins you better have a look at PrtMip property
in Access help.

--
Saludos desde Barcelona
Juan M. Afan de Ribera
<MVP Ms Access>
http://www.juanmafan.tk
http://www.clikear.com/webs4/juanmafan
 
dans l'article (e-mail address removed), Juan M. Afan de Ribera
à (e-mail address removed) a écrit le 3/11/03 21:32 :
If you are using Access XP or above you can use the Printers collection to
choose a specific printer.....

Thank you for your help
 
Back
Top