Situation:
I have word file and a checklist
If the column B of the checklist has the a cell name equal to a bookmark title in word file then must replace the bookmark with the content of the column F of clause sheet
Note:
Column D of clause sheet it is kind an ID = bookmark title = cell name of column B of the checklist
I have done kind of an piece of code but isn't working.
Can someone help me:
I have word file and a checklist
If the column B of the checklist has the a cell name equal to a bookmark title in word file then must replace the bookmark with the content of the column F of clause sheet
Note:
Column D of clause sheet it is kind an ID = bookmark title = cell name of column B of the checklist
I have done kind of an piece of code but isn't working.
Can someone help me:
VBA Code:
[
'6. Update clauses - Sixth PHASE
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
strClausesSheet = "Clauses"
strMappingPath = "C:\Add-in\CCopy of Mapping.xlsx"
Set wbMapping = Workbooks.Open(strMappingPath)
wbMapping.Activate
Sheets(strClausesSheet).Activate
ExcelNavette.Activate
ExcelNavette.Sheets("Navette").Activate
Set Navette = ExcelNavette.Sheets("Navette")
Dim i As Integer
For i = 2 To wbMapping.Sheets(strClausesSheet).Cells(clausesSheet.Rows.Count, "B").End(xlUp).row
If ExcelNavette.Sheets("Navette").Range("B" & i).Value = "Oui" And ExcelNavette.Sheets("Navette").Range("B" & i).Name.Name = wbMapping.Sheets(strClausesSheet).Range("D" & i).Value Then
'Replace the bookmark with the value in column F of the Clauses sheet
WordDoc.Bookmarks(clausesSheet.Range("B" & i).Name.Name).Range.Text = wbMapping.Sheets(strClausesSheet).Range("F" & i).Value
End If
Next i
]