Replace bookmarks using excel

nmc

New Member
Joined
Aug 25, 2022
Messages
38
Office Version
  1. 2021
Platform
  1. Windows
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:
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
]
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top