Chào Thầy, nhờ Thầy chỉ ra lỗi sai và hướng dẫn lại đoạn code xem lương bằng file PDF. Cám ơn
chào bạn bạn có thể đẩy file lên được không?
https://drive.google.com/file/d/1uXkU...
Gửi Thầy đường liên kết, nhờ Thầy hướng dẫn. Cám ơn
Chào bạn bạn cho mình xin quyền truy cập nhé.
Dạ, 123
Chào bạn bạn mở quyền truy cập để mình xem được file của bạn nhé.
Dạ đã mở quyền truy cập, nhờ Thầy xem giúp
chào bạn bạn xem code này nhé.
Option Explicit
Sub PhieuLuong_NoiDung()
Dim dong_BD As Long, dong_KT As Long
dong_BD = Application.WorksheetFunction.Match(Sheet2.Range("E4"), Sheet1.Range("A7:A200"), 0) + 5
dong_KT = Application.WorksheetFunction.CountIf(Sheet1.Range("A7:A200"), Sheet2.Range("E4")) + dong_BD - 1
Sheet2.Select
Dim i As Integer
For i = dong_BD To dong_KT
Sheet2.Range("B7").Value = Sheet1.Range("B" & i).Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Range("b7") & ".pdf"
Next i
End Sub
chào bạn bạn thử giúp mình lưu file vào đường dẫn không giấu như destop và thử lại xem
Dạ, Em đang lưu tại destop ạ
chào bạn bạn có ultraview đấy không mình vào xem thử
dạ có
đã gửi mail cho Thầy
chúc bạn học tốt cùng gitiho, lần sau bạn cứ chủ động đăng lên trên này nhé.
Chào Thầy, Thầy xem giúp đoạn code này sai ở đâu mà khi xuất ra file pdf không đọc được
Sub taods()
Dim i As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
i = 7
With ThisWorkbook.Sheets("Data_T.Luong")
While (.Cells(i, 2) <> "")
ThisWorkbook.Sheets("Phieu luong").Cells(7, 3) = .Cells(i, 2)
ThisWorkbook.Sheets("Phieu Luong").copy
'Luu file sau khi xuat vao folder danh sach va dat pass
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\Danh Sach\" & .Cells(i, 2) & "_" & .Cells(i, 4) & ".pdf", Password:=.Cells(i, 3)
ActiveWorkbook.Close
i = i + 1
Wend
End With
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
Chào Thầy, nhờ Thầy xem giúp đoạn code. Khi xuất ra file pdf xem không được file
Sub taods()
Dim i As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
i = 7
With ThisWorkbook.Sheets("Data_T.Luong")
While (.Cells(i, 2) <> "")
'Gán ma cho tung nhan vien
ThisWorkbook.Sheets("Phieu luong").Cells(7, 3) = .Cells(i, 2)
'Trich xuat shhet Form ra file moi
ThisWorkbook.Sheets("Phieu Luong").copy
'Luu file sau khi xuat vao folder danh sach va dat pass
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\Danh Sach\" & .Cells(i, 2) & "_" & .Cells(i, 4) & ".pdf", Password:=.Cells(i, 3)
ActiveWorkbook.Close
i = i + 1
Wend
End With
'Hien thong bao ket thuc chuong trinh
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
Chào bạn bạn cho mình xin quyền truy cập
Dạ đã mở quyền truy cập, nhờ Thầy xem giúp
Chào bạn bạn mở lại giúp mình nhé.
Em gửi lại Thầy
Chào bạn bạn bạn vẫn chưa mở ra ạ.
Dạ, đã gửi mail cho Thầy
Thầy em lại giúp ạ
Đã mở quyền truy cập, nhờ Thầy xem giúp. Cám ơn
Chào bạn Excel và word không hỗ trợ việc xuất ra pdf có mật khẩu :
Link tham khảo
https://stackoverflow.com/questions/4...
code trong file của bạn sủa để chạy:
Sub taods()
Dim i As Integer
'Bo qua canh bao va nhap nhay khi chay chuong trinh
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Gán gia tri dau tien
i = 7
'Quét tung nhan vien 1
With ThisWorkbook.Sheets("Data_T.Luong")
Do While (.Cells(i, 2) <> "")
'Gán ma cho tung nhan vien
ThisWorkbook.Sheets("Phieu luong").Cells(7, 3) = .Cells(i, 2)
'Trich xuat shhet Form ra file moi
ThisWorkbook.Sheets("Phieu Luong").copy
'Luu file sau khi xuat vao folder danh sach va dat pass
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & .Cells(i, 2) & "_" & .Cells(i, 4) & ".PDF", Password:=.Cells(i, 3)
ActiveWorkbook.Close
i = i + 1
Loop
End With
'Hien thong bao ket thuc chuong trinh
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
file bị lỗi không đọc được Thầy ơi
Chào bạn đúng rồi bạn xuất ra định dạng lưu sai đuôi sao đọc được mình nói rồi định dạng pdf không hỗ trợ đặt mật khẩu đây là định dạng file excel
dạ bỏ đặt pass luôn cũng không được
....ActiveWorkbook.SaveAs ThisWorkbook.Path & "\Danh Sach\" & .Cells(i, 2) & "_" & .Cells(i, 4) & ".PDF"
Chào bạn bạn thử như sau nhé.
Sub taods()
Dim i As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
i = 7
With ThisWorkbook.Sheets("Data_T.Luong")
Do While (.Cells(i, 2) <> "")
'Gán ma cho tung nhan vien
ThisWorkbook.Sheets("Phieu luong").Cells(7, 3) = .Cells(i, 2)
'Trich xuat shhet Form ra file moi
''ThisWorkbook.Sheets("Phieu Luong").copy
'Luu file sau khi xuat vao folder danh sach va dat pass
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Sheet1.Cells(i, 2) & ".Pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
'ActiveWorkbook.Close
i = i + 1
Loop
End With
'Hien thong bao ket thuc chuong trinh
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
Dạ, cám ơn Thầy
Chúc bạn học tốt cùng gitiho