Xin chào mọi người, em là lính mới trong lập trình vba. Em copi đoạn code vào mà chạy toàn báo lỗi variable not defined , em tìm mãi mà ko rõ sai chỗ nào, mong mọi người chỉ giúp em với
				
			
Sub Xuatfile()
  
    Dim i As Long, j As Long
    Dim template As Object
    Dim t As Object
    i = 1
       
    With CreateObject("word.application")
        .Visible = True
       
            Set template = .documents.Open("C:\temp\hopdong_temp.docx")
            Set t = template.Content
           
                t.Find.Execute _
                    FindText:="abc", _
                    ReplaceWith:="def", _
                    Replace:=wdReplaceAll
          
            template.SaveAs Filename:=ThisWorkbook.Path & Application.PathSeparator & i & "-giay_moi.docx"
        .Quit
    End With
    Set t = Nothing
    Set template = Nothing
End Sub
File đính kèm
			
				Lần chỉnh sửa cuối: 
			
		
	
								
								
									
	
								
							
							
	
	  

