View Single Post
 
Old 08-12-2021, 04:28 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The code you posted looks problematic as you could delete content all over the document if it gets a mention in oldPN. In my opinion, bookmarks are too unwieldy to use nowdays - especially where there are more than one instance you need to find - you should be using Content Controls instead.

For instance, if the CCs had a title of PNBox you could update the content in each with
Code:
Sub CCupdate()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.SelectContentControlsByTitle("PNBox")
    aCC.Range.Text = "hello"
  Next aCC
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote