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:)
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,413
Messages
5,511,189
Members
408,829
Latest member
sheshe123

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top