I have found a way to copy the values from each of the Excel named ranges to bookmarks with the same name in Word using the following piece of code:
However, this removes the existing bookmarks in Word. Is there a way to either preserve the bookmarks or to recreate the bookmarks using the named ranges in Excel? I need to preserve the bookmarks because they are referred to elsewhere in the document.
Thanks!
'Loop through names in the activeworkbook
For Each xlName In wb.Names
'if xlName's name exists in the document then put the value at the bookmark
If MyDoc.Bookmarks.Exists(xlName.Name) Then
MyDoc.Bookmarks(xlName.Name).Range.Text = Range(xlName.Value)
End If
Next xlName
For Each xlName In wb.Names
'if xlName's name exists in the document then put the value at the bookmark
If MyDoc.Bookmarks.Exists(xlName.Name) Then
MyDoc.Bookmarks(xlName.Name).Range.Text = Range(xlName.Value)
End If
Next xlName
However, this removes the existing bookmarks in Word. Is there a way to either preserve the bookmarks or to recreate the bookmarks using the named ranges in Excel? I need to preserve the bookmarks because they are referred to elsewhere in the document.
Thanks!