PDA

View Full Version : VBA and printing



francozola25
08-10-2008, 09:56 AM
Hello i have a problem with printing

I currently have 4 users that will automatically print documents single sided in vba. I have 1 main user and 3 back up users when that person is not around.

currently for my main user they are connected to a printer call formsprinter which has a settings that it will print single sided.


ActivePrinter = "formsprinter"
bDoc.PrintOut


My problem is that my other 3 users will not be able to connect to this printer as formsprinter is a local printer for the main user.

I want to then say
if formsprinter exists then
ActivePrinter = "formsprinter"
bDoc.PrintOut
else
bDoc.PrintOut

I will have to tell my other three users to make sure they have the option set to single-sided before printing off. Is there are easier way or could someone help me with the syntax on formsprinter?

mdmackillop
08-10-2008, 01:01 PM
Sub Prints()
On Error Resume Next
ActivePrinter = "formsprinter"
bDoc.PrintOut
End Sub

macropod
08-10-2008, 03:44 PM
Hi francozola25,

I'd suggest checking whether the person currently logged on is the one who has access to the formsprinter. If not, print to the local printer. You could do this with code like:

Dim DefPrinter As String
DefPrinter = Application.ActivePrinter
If Environ("Username") = "Supervisor" Then Application.ActivePrinter = "formsprinter"
bDoc.PrintOut
Application.ActivePrinter = DefPrinterreplacing 'Supervisor' with the person's logon ID and 'formsprinter' with the real printer name.

francozola25
08-11-2008, 01:10 AM
Thanks for that guys

Worked brillantly