Printer Choice

OldManRiver

Registered User.
Local time
Today, 16:00
Joined
Jan 29, 2009
Messages
49
All,

Does anyone have a link to a good example of how to call a printer in VBA?

Thanks!

OMR
 
What ??

All,

The HOWTOs all say this code should work:
Code:
Sub SetPrinter(DevName)
    Dim objPrinter
'    Dim objPrinter as Printer
'    Set Application.Printer = objXL.Application.Printers(0)
    Set objPrinter = objXL.Application.Printer
'    For Each objPrinter In objXL.Application.ActivePrinter
'    For Each objPrinter In objXL.Application.Printers
    For Each objPrinter In Application.Printers
        If objPrinter.DeviceName = DevName Then
            Set Printer = objPrinter
            Exit For
        End If
    Next
    Set objPrinter = Nothing
End Sub
But always error with:
Object doesn't support thsi property or method
When I try to use the"

Dim objPrinter as Printer

I get a User Object error on the "Printer", so everything goes whack after that.

Open to inputs!!

Thanks!

OMR
 
Partial Fix

All,

Found part of my problem. I'm trying to use the routine in VBA for both Access and Excel. They do not handle the same.

Access loves the "Dim objPrinter as Printer" but Excel hates it.

Need a way to make a routine that satisfies both.

OMR
 
Sometimes knowing the ultimate goal leads to a more logical solution. What is the object of the exercise?

David
 
And, as Access and Excel have two different object models, it may be that you can't use the same one for both.
 

Users who are viewing this thread

Back
Top Bottom