ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change ActivePrinter in a Add-In (https://www.excelbanter.com/excel-programming/445092-change-activeprinter-add.html)

Ludo

Change ActivePrinter in a Add-In
 
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

Ludo

Change ActivePrinter in a Add-In
 
On 3 nov, 10:18, Ludo wrote:
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


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com