Change ActivePrinter in a Add-In

L

Ludo

Hi all,

I'm converting a .xls application with a lot of forms & some modules
to a ADD-IN.
The problems i met while converting are most solved by info i found on
this forum, thank you all a lot for it ;).
But, i still have a problem.

I need sometimes to change from printer, depending on a single
criteria.
I use in the .xls file following code:

Application.ActivePrinter = ProductionPrinter

This works fine as long as the 'IsAddIn' property is set to false.
If i set this property to True, then i get a fail message.

How can i change the active printer to another printer in a Add-In?

Thanks in advance.
Regards,
Ludo
 
L

Ludo

Hi all,

I'm converting a .xls application with a lot of forms & some modules
to a ADD-IN.
The problems i met while converting are most solved by info i found on
this forum, thank you all a lot for it ;).
But, i still have a problem.

I need sometimes to change from printer, depending on a single
criteria.
I use in the .xls file following code:

Application.ActivePrinter = ProductionPrinter

This works fine as long as the 'IsAddIn' property is set to false.
If i set this property to True, then i get a fail message.

How can i change the active printer to another printer in a Add-In?

Thanks in advance.
Regards,
Ludo

Hi all,

I think i found a workaround, by using the same trick as when you want
to add extra sheets into an Add-In.
Simply set the ThisWorkbook.IsAddin = False
After changing your printer, set it back to True.

See example that i use:

'Print
'ProductionPrinter = print on white paper = default printer
'Csgprinter = print on yellow paper (different printer than the
default printer!)
'
'check for printer(CSG)if white or yellow paper needed
Application.ScreenUpdating = False
' set Production printer as active printer & print sheet 'Dagverloop'
ThisWorkbook.IsAddin = False
Application.ActivePrinter = ProductionPrinter
'print to default printer
ThisWorkbook.Sheets("dagverloop").PrintOut
'
For Dummy = 1 To NumberOfUnits
If frmFollowupSheets.Controls("lblserialnumber" &
Dummy).Caption > "" Then '
' set CSGPrinter as active printer
If CSG(Dummy) = True Then
Application.ActivePrinter = Csgprinter
Else
' set Production printer as active printer
Application.ActivePrinter = ProductionPrinter
End If
'print active sheet to active printer
ThisWorkbook.Sheets("toestel" & Dummy).PrintOut
ActivePrinter:=Application.ActivePrinter
End If
Next
ThisWorkbook.IsAddin = True

Hope to help someone with it when needed.

Regards,
Ludo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top