As far as I know it will not be possible to achieve what you are trying to,
by a simple macro.
Other way, I can think of, is to print each invoice to a file (prn file)
using the following code. Then combine all the prn files into one(using
macro). Then sending the print command using shell_execute or by directly
using command line.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Name of the printer", PrintToFile:=True, PrToFileName:="c:\x" & i &
".prn"
But I wonder whether there is any specific reason to avoid sending 11
separate print jobs (in your example).
Akhilesh Kumar Karna
On Thu, May 21, 2009 at 2:08 AM, Dustin <[email protected]> wrote:
>
> Akhilesh,
>
> Thank you for your response. Though that line is helpful, it is not
> what I need. Maybe this simple example will help clarify:
>
> Sub test()
>
> For i = 0 To 10
> Range("A1").Select
> ActiveCell.FormulaR1C1 = i
> ActiveWindow.SelectedSheets.PrintOut Copies:=1
> Next
> End Sub
>
> The way that this is currently written, there will be 11 separate
> print jobs sent to the printer, resulting in 11 pages.
>
> What I would like to do is to have only ONE print job sent to the
> printer, which will result in 11 pages. Does that help?
>
> Dustin
>
> On May 12, 2:10 am, Akhilesh Karna <[email protected]> wrote:
> > Maybe I got it wrong. But if I understand correctly, then you can use the
> > following code at the end of the loop ( when your data is being read to
> the
> > invoice).
> >
> > ActiveWindow.SelectedSheets.PrintOut Copies:=1
> >
> > Hope you make your problem more clear if the above does not help.
> >
> > Akhilesh Kumar Karna
> >
> > On Tue, May 12, 2009 at 6:57 AM, Dustin <[email protected]> wrote:
> >
> > > Dear All,
> >
> > > I have an invoice template, which reads different data from other
> > > worksheets in the workbook through a for loop. Each iteration of the
> > > loop is a different customer and hence a new invoice. Currently, I am
> > > searching for a way to print these invoices (a few hundred) in a
> > > single print job, instead of a few hundred single-page print jobs.
> >
> > > My initial thought was to have a macro which copied each invoice to a
> > > word document and have each new invoice be a new page, then simply
> > > print the word document. I believe this is still the ideal case,
> > > though I am having a very difficult time keeping the formatting of the
> > > invoice intact during this transfer. The closest I have gotten is to
> > > use the picture-copy method in VBA:
> > > ...
> > > Worksheets("Invoice").Range("A1:R80").CopyPicture _
> > > Appearance:=xlScreen, Format:=xlPicture
> >
> > > WordApp.Selection.Paste
> > > ...
> >
> > > Though this is less than ideal since the invoice is now a picture
> > > instead of a table which can be edited.
> >
> > > I am certainly open to any other way to accomplish this as well.
> >
> > > What are your thoughts on this?
> >
> > > MUCH appreciated =] ... I love this group.
> >
> > > Dustin
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain @ [email protected] or
Ashish Jain @ [email protected]
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---