Các anh chị ơi, cho em hỏi.
Em có đọc được bài hướng dẫn của bạn này ý ạ. Nhưng vấn đề của e là Folder PKN được chia nhỏ ra thành từng ngày như này.
Thì code nên sửa lại như thế nào ạ ??? Vì công việc hiện tại của e phải in tầm 10 hóa đơn theo danh sách excel, trong 1 tháng 24 ngày. Tổng cộng trên 10.000 hóa đơn nên k thể gộp thành 1 folde được ý ạ.
Code được ghi trong bài ạ. https://www.giaiphapexcel.com/diendan/threads/in-file-pdf-theo-danh-sách-trong-excel.141026/
Option Explicit
#If VBA7 Then
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
#Else
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If
Public Function PrintThisDoc(formname As Long, FileName As String)
On Error Resume Next
Dim X
X = ShellExecute(formname, "Print", FileName, 0&, 0&, 3)
End Function
Sub testPrint()
Dim printThis, Arr()
Dim strDir As String
Dim i As Integer
strDir = ThisWorkbook.Path & "\PKN\"
Arr = Sheet2.Range("C2:C" & Sheet2.Range("C65000").End(xlUp).Row).Value
For i = 1 To UBound(Arr)
printThis = PrintThisDoc(0, strDir & Arr(i, 1) & ".PDF")
Next i
End Sub
E cảm ơn mọi người ạ

Em có đọc được bài hướng dẫn của bạn này ý ạ. Nhưng vấn đề của e là Folder PKN được chia nhỏ ra thành từng ngày như này.
Thì code nên sửa lại như thế nào ạ ??? Vì công việc hiện tại của e phải in tầm 10 hóa đơn theo danh sách excel, trong 1 tháng 24 ngày. Tổng cộng trên 10.000 hóa đơn nên k thể gộp thành 1 folde được ý ạ.
Code được ghi trong bài ạ. https://www.giaiphapexcel.com/diendan/threads/in-file-pdf-theo-danh-sách-trong-excel.141026/
Option Explicit
#If VBA7 Then
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
#Else
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If
Public Function PrintThisDoc(formname As Long, FileName As String)
On Error Resume Next
Dim X
X = ShellExecute(formname, "Print", FileName, 0&, 0&, 3)
End Function
Sub testPrint()
Dim printThis, Arr()
Dim strDir As String
Dim i As Integer
strDir = ThisWorkbook.Path & "\PKN\"
Arr = Sheet2.Range("C2:C" & Sheet2.Range("C65000").End(xlUp).Row).Value
For i = 1 To UBound(Arr)
printThis = PrintThisDoc(0, strDir & Arr(i, 1) & ".PDF")
Next i
End Sub
E cảm ơn mọi người ạ
