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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

Prabhu_Bob

New Member
Joined
Feb 19, 2010
Messages
19
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:)
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

Prabhu_Bob

New Member
Joined
Feb 19, 2010
Messages
19
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
 

Watch MrExcel Video

Forum statistics

Threads
1,132,994
Messages
5,656,286
Members
418,292
Latest member
spd87

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
Top