Link to home
Start Free TrialLog in
Avatar of carruina
carruina

asked on

Change the paper bin with VB

I have an application that open an Excel Sheet, write some
data and print this Sheet.

Now I need change the printer and the paper bin to send this file to diferents printers.

I try with this code but don't work


'Search the printer pImpresora
For Each Auxprinter In Printers
    If Auxprinter.DeviceName = Trim(pImpresora) Then
        PrintEnc = True
        Set Printer = Auxprinter
        Exit For
    End If

If PrintEnc Then
    Printer.PaperBin = pBandeja
    xlSheet.PrintOut , , pCopias, , Printer.DeviceName
Else 'Send the file to the default printer if pImpresora doen't exists.
    xlSheet.PrintOut , , pCopias, , Printer.DeviceName
   
End If

I can send the file to diferents printers (pImpresora) but I can't change the paperbin.

Thanks in advance for your colaborations
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Avatar of carruina

ASKER

angelIII :
That don´t solve my problem because when I print the document with excel and It don't take the correct paperbin
 xlSheet.PrintOut , , pCopias, , Printer.DeviceName
Take the default paperbin of the printer.
rpai:

This example is good but Doesn´t work with Excel 97:

I can't set a printer object to a Excel Sheet

Thanks
ASKER CERTIFIED SOLUTION
Avatar of PNJ
PNJ

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tested your function and works fine

The printer has this possibilities:
1,2,3,14,4,6,7

I always try to use paperbin 1 and 2

I don't have any problem to change the paperbin and this works fine if I print from visual basic.

The problem appears when I want print using Excel from Visual Basic.

I change the paperbin but when send the file with this command line "xlSheet.PrintOut , , pCopias, , Printer.DeviceName" Excel gets the system configuration of this printer.

I need change the printer configuration with VB but permanently.

For example when you use Printer Object the changes, that you do it, only are "visible" in the application VB. If you close the application and see in the printers control panel the configuration are the previosly. And this is the configuration of the printer.
I tested your function and works fine

The printer has this possibilities:
1,2,3,14,4,6,7

I always try to use paperbin 1 and 2

I don't have any problem to change the paperbin and this works fine if I print from visual basic.

The problem appears when I want print using Excel from Visual Basic.

I change the paperbin but when send the file with this command line "xlSheet.PrintOut , , pCopias, , Printer.DeviceName" Excel gets the system configuration of this printer.

I need change the printer configuration with VB but permanently.

For example when you use Printer Object the changes, that you do it, only are "visible" in the application VB. If you close the application and see in the printers control panel the configuration are the previosly. And this is the configuration of the printer.
Hi carruina,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept PNJ's comment(s) as an answer.

carruina, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Accept for the recomendation of the moderator