Printing subset of pages dynamically using excel macros

N

nsgargya

Hi All:

I am trying to use Excel VBA macro to dynamically print certain number
of pages.

Let me explain:

I have a print button in the second page of my spreadsheet. When I
click this button I have to start ptinting from second page onwards .
But the end is dynamic. Depending on the number of records available it
can vary (i.e can be 10 records or 40 or 30 or2 etc).

I would really appreciate if some one could help me with this scenario.


I very badly need this in my project.

Thanks in advance

nsgargya
 
R

Ron de Bruin

Hi

Try

Sub Test()
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
ActiveSheet.PrintOut From:=2, To:=TotPages
End Sub
 
Top