• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

ERROR MACRO FOR PRINTING EXCEL FILE

VIX

New Member
We are using the following code for printing the excel files as PDF which will pick file names from range of cells, everything works fine but the problem is it does not captures first file name, means we need to enter the first file name manually.
Code:
Sub Printing()
Dim pages As Integer
Dim fname As String
pages = 1
fname = Worksheets("FILENAME").Range("c3").Value
Application.DisplayAlerts = False
Do
Worksheets("Sal Slip - PM").Activate
Worksheets("Sal Slip - PM").PrintOut From:=pages, To:=pages
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 2
waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
filename = Range("B11") & fname
SendKeys filename & "{enter}"
pages = pages + 1
fname = Worksheets("FILENAME").Range("c2").Offset(pages, 0)
Loop Until pages > Cells(3, 2)
Application.DisplayAlerts = True
End Sub
 
One more issue with the code is after execution it writes the path in the active cell kindly help with this
 
Back
Top