Copy Named Range from Excel to Word Bookmark, Preserving Bookmarks? (VBA)

spudweb

New Member
Joined
Apr 2, 2014
Messages
1
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:

'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​

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!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,216,157
Messages
6,129,195
Members
449,493
Latest member
JablesFTW

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