truongtrungkien1986@gmail
Yêu THVBA
Em có 1 file excel muốn chuyển sang word nhưng viết VBA chưa đúng toàn báo lỗi. xin các bác sửa hộ em chút ạ
download file:
Mã:
Sub Dulieu()
Dim num_of_cust As Long
Dim num_of_column As Long
Dim i As Long, j As Long
Dim template As Object
Dim t As Object
num_of_column = 5
num_of_cust = DU_LIEU.Cells(Rows.Count, "A").End(xlUp).Row - 1
With CreateObject("word.application") ' late binding
.Visible = True
For i = 1 To num_of_cust
Set template = .documents.Open("C:\Users\TRUNG KIEN\Desktop\BB VPHC\TEST.docx")
Set t = template.Content
For j = 1 To num_of_column
t.Find.Execute _
FindText:=DU_LIEU.Cells(1, j).Value, _
ReplaceWith:=DU_LIEU.Cells(i + 1, j).Value, _
Replace:=wdReplaceAll
Next
template.SaveAs Filename:=ThisWorkbook.Path & Application.PathSeparator & i & "-BBVPHC.docx"
Next
.Quit
End With
Set t = Nothing
Set template = Nothing
End Sub
Bạn cần đăng nhập để thấy link