PC Review


Reply
Thread Tools Rate Thread

Change ActivePrinter in a Add-In

 
 
Ludo
Guest
Posts: n/a
 
      3rd Nov 2011
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
 
Reply With Quote
 
 
 
 
Ludo
Guest
Posts: n/a
 
      15th Nov 2011
On 3 nov, 10:18, Ludo <ludo.so...@scarlet.be> 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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:05 AM.