i have this macro added in excel,
this macro prints the excel files one by one in a specified folder, thsi works fine
the problem is that i need to add the increment number in all the workbooks( suppose i have 200 workbooks, i need to add 1, 2 , 3 and on and on in the header of all workbooks )each workbook contains only one sheet pls help to me to do the same
heres the code which is working fine to print the workbooks
Sub Print_And_Move()
PrintFiles
MoveFiles
End Sub
Private Sub PrintFiles()
‘will print all excel files in C:\Data
Dim i As Long
Dim WB As Workbook
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = “p:\” ‘****Change path here*****
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Set WB = Workbooks.Open(.FoundFiles(i))
WB.PrintOut Copies:=1
WB.Close False
Next i
End If
End With
Application.ScreenUpdating = True
End Sub
Private Sub MoveFiles()
Dim filelist() As Variant
ReDim filelist(1 To 1)
Dim srcPath As String
Dim destPath As String
Dim sFile As String
Dim i As Long
srcPath = “p:\” ‘****Change path here*****
destPath = “p:\print\” ‘****Change path here*****
sFile = Dir(srcPath & “*.xls”)
Do While sFile <> “”
filelist(UBound(filelist)) = sFile
ReDim Preserve filelist(1 To UBound(filelist) + 1)
sFile = Dir
Loop
For i = 1 To UBound(filelist) – 1
Name srcPath & filelist(i) As destPath & filelist(i)
Next i
End Sub