Hi,
I would like to code VBA form excel to add data to each cell of the table for the attached word file.
I use following code:
Sub Thu()
Dim objWord
Dim objDoc
Dim intParaCount
Dim objParagraph
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("D:\X61\X61.docx")
objWord.Visible = True
intParaCount = objDoc.Paragraphs.Count
'MsgBox intParaCount
Set objParagraph = objDoc.Paragraphs(3).Range
objParagraph.Find.Text = "y th"
Do
objParagraph.Find.Execute
If objParagraph.Find.Found Then
objParagraph.Text = "y 20 th"
End If
Loop While objParagraph.Find.Found
Set objParagraph = objDoc.Paragraphs(3).Range
objParagraph.Find.Text = "g n"
Do
objParagraph.Find.Execute
If objParagraph.Find.Found Then
objParagraph.Text = "g 11 n"
End If
Loop While objParagraph.Find.Found
Set objParagraph = objDoc.Paragraphs(3).Range
objParagraph.Find.Text = "mf"
Do
objParagraph.Find.Execute
If objParagraph.Find.Found Then
objParagraph.Text = "m 2020"
End If
Loop While objParagraph.Find.Found
Set objParagraph = objDoc.Paragraphs(13).Range
objParagraph.Find.Text = "1"
Do
objParagraph.Find.Execute
If objParagraph.Find.Found Then
objParagraph.Text = "ABC"
End If
Loop While objParagraph.Find.Found
End Sub
But I can only change data for the 1st row of the table.
Please help me to change data for the 2nd row of the table.
Bookmarks