Print in same tiff using VBA

Prabhu_Bob

New Member
Joined
Feb 19, 2010
Messages
19
I have written the printout code in VBA within DO loop so that it prints correctly but as seperate files. The problem is that it is printing corectly but in seperate tiff's. I don't want it to be like that instead it should print page after page in a single tiff. I wanted the VBA code to do that. Please kindly help.

Thanks,
Prabhu:)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Can you post you code please? You could copy all the ranges that you want to print to a new worksheet and print that worksheet to TIFF.
 
Upvote 0
Hi Andrew,

I have shown you a sample but in the original code the range is bigger where sheet1 uses employee details -sal, DOH, DOB etc for payroll.
Sheet two has an template for the payslip. I am printing the template within the loop so that tiff/payslip is created for all the employees.

I needed a change in code so that all payslips/tiffs fall under one single tiff (page after page) instead of printing multiple seperate tiffs.

i = 1
DO until sheet1.cells(i,1) <> ""
'sheet1 is the employee details
'sheet2 is a report template
sheet2.cells(i,1) = sheet1.cells(i,1)
sheet2.cells(i,2) = sheet1.cells(i,2)
sheet2.cells(i,3) = sheet1.cells(i,3)
pathwithfilename = "path" &filename &".tiff"
sheet2.range("A1:A3").printout from:=1, to:=1, copies:=1,prtofile:=true collate:=true,prtofilename:=pathwithfilename
i = i+1
loop

THanks,
Prabhu:)
 
Upvote 0
Please post your real code, not pseudo code. That code does nothing because until should be while. Also it writes to A1:C1 but prints A1:A3.
 
Upvote 0
Ok this is the real code. I just wanted to print in single file. Please help

i = 1
DO until sheet1.cells(i,1) <> ""
'sheet1 is the employee details
'sheet2 is a report template
sheet2.cells(i,1) = sheet1.cells(i,1)
sheet2.cells(i,2) = sheet1.cells(i,2)
sheet2.cells(i,3) = sheet1.cells(i,3)
pathwithfilename = "D:\Prabhu\" & sheet1.cells(i,1) &".tiff"
sheet2.range("A1:C3").printout from:=1, to:=1, copies:=1,prtofile:=true collate:=true,prtofilename:=pathwithfilename
i = i+1
loop

Thanks,
Prabhu
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top