We help IT Professionals succeed at work.
Get Started

In the range I select only prints the first PDF of the seleted rows

192 Views
Last Modified: 2010-04-30
I select an excel range, and try to print the PDF Documents
E.g
26/06/2008      RUN Property (NSW)      000000002730981      Body Corporate Cleaning ServiceTony And Marie Moubarak      Inv 83      89.31      98.24 I:\Docs\CY1000001RPMPROD\Documents\2008\06\25 000000001057034_20080625_121119_cleaning_invoice.pdf

26/06/2008      RUN Property (NSW)      000000002730981      Body Corporate Cleaning Service Firmack Pty Ltd      Inv 83      87.26      95.99      I:\Docs\CY1000001\RPMPROD\Documents\2008\06\25\000000001057042_20080625_121939_cleaning_invoice.pdf

My Problem is it only prints the pdf in the first row, it doesnt print the pdf document from  the second row onwards.
Sub PrintPDFDocument()
Dim strDocument As String, strExecutable As String
    strPrinterName = Application.ActivePrinter
    strDriverName = GetPrinterDetails.DriverName
    strPortName = GetPrinterDetails.PortName
    strExecutable = GetExecutablePath("pdf") ' get the path to Acrobat Reader
    If Len(strExecutable) > 0 Then
        ' Set the current cell to A1
                   
        Range("I1").Activate
        ' Loop until we get to the end of the data
        Do While Not ActiveCell.Row = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
            strDocument = ActiveCell.Cells.Value
            Shell strExecutable & " /p " & strDocument
            ' Can't seem to get the following bit of code to work for some reason
            ' Shell strExecutable & " /t " & strDocument & " " & strPrinterName & " " & strDriverName & " " & strPortName
            ActiveCell.Offset(1, 0).Range("I1").Select
            
        Loop
    End If
End Sub

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE