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