-
Dec 31st, 2012, 11:52 AM
#1
Thread Starter
Lively Member
[RESOLVED] Print data report on non-default printer
I need to automatically print datareport on non-default printer.
Mi default printer is 'Hp 1020'
Datareporty need to print to a printer \\Tmk_print_serve\lp1
When I run my code so datareport default printer and print a test text prints the correct printer. How is it possible? Why not print only on one printer?
What code should I use to datareport printed on: \\Tmk_print_serve\lp1
DataReport1.Show
Dim prt As Printer
For Each prt In Printers
If prt.DeviceName = "\\Tmk_print_serve\lp1" Then
Set Printer = prt
Exit For
End If
Next
DataReport1.PrintReport
Printer.Print "test"
Thx
-
Dec 31st, 2012, 12:39 PM
#2
Re: Print data report on non-default printer
Try changing windows default printer to whatever you need, print report and then change printer back to original.
Sample 1
Sample 2
-
Dec 31st, 2012, 01:59 PM
#3
Re: Print data report on non-default printer
Never used the data report but is there an option to set the printer as part of the report properties?
Been a while since I needed to do this and can't remember for sure how I did it but it was either by setting the VB Printer object to the desired printer or perhaps my report tool has an option to set the printer for the report.
You should not need to modify the windows default printer in any way to do this.
-
Jan 1st, 2013, 06:37 AM
#4
Thread Starter
Lively Member
Re: Print data report on non-default printer
Please try to remember it's important to me.
Prints all the string datareportu datareport but still prints on the default printer.
For now, I'll try to change the system printer.
Thx RhinoBull
-
Jan 1st, 2013, 09:32 AM
#5
Re: Print data report on non-default printer
Looking at your code in the first post I think you solution may be as simple as moving some code around. Try setting the printer before you load the report. In the code posted you are showing the report and then changing the printer. I can't be sure about the data report tool but the report engine I use will work with the VB printer object that is active at the time the report is loaded. It will format the report based on this printer object and if you tell it to print without prompting for the printer to use then it will use the printer that was active when the report was loaded.
Code:
Dim prt As Printer
For Each prt In Printers
If prt.DeviceName = "\\Tmk_print_serve\lp1" Then
Set Printer = prt
Exit For
End If
Next
DataReport1.Show
DataReport1.PrintReport
Printer.Print "test"
-
Jan 1st, 2013, 11:23 AM
#6
Thread Starter
Lively Member
Re: Print data report on non-default printer
RESOLVED!
Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszPrinter As String) As Long
Dim PrintData As Printer
Dim defprinterpos As Integer
For Each PrintData In Printers
If PrintData.DeviceName = Printer.DeviceName Then
sys_default_printer = Printer.DeviceName
End If
Next
REM ... DATAREPORT CODE ...
REM ... DATAREPORT CODE ...
REM ... DATAREPORT CODE ...
Dim docasna_tiskarna As String
docasna_tiskarna = "\\Tmk_print_serve\lp1"
SetDefaultPrinter docasna_tiskarna 'REM API SetDefaultPrinter
DataReport1.PrintReport
SetDefaultPrinter sys_default_printer 'REM API SetDefaultPrinter -- back sys.def.printer
rem THX ALL
-
May 23rd, 2014, 08:37 PM
#7
New Member
Re: [RESOLVED] Print data report on non-default printer
Thanks for this answer Tomasek-TMK , works greate!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|