Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2022, 09:35 PM
macropod's Avatar
macropod macropod is offline Trouble removing cross-references Windows 10 Trouble removing cross-references Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

What the _Ref111185707 refers to is a hidden bookmark, not a cross-reference. In your attachment, that bookmark is applied to the '2'. Delete the hidden bookmark via the Insert|Bookmark dialogue (check the 'hidden bookmarks' option to see it) and all will be well.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 08-14-2022, 06:51 AM
BrianHoard BrianHoard is offline Trouble removing cross-references Windows 10 Trouble removing cross-references Office 2019
Advanced Beginner
Trouble removing cross-references
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

So glad you found this, can't wait to try your steps. I'm hoping I'll be able to do as you say via VBA. I'll try recording a macro of this and see if I can write a script to clean these up.
Reply With Quote
  #3  
Old 08-14-2022, 12:06 PM
BrianHoard BrianHoard is offline Trouble removing cross-references Windows 10 Trouble removing cross-references Office 2019
Advanced Beginner
Trouble removing cross-references
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
What the _Ref111185707 refers to is a hidden bookmark, not a cross-reference. In your attachment, that bookmark is applied to the '2'. Delete the hidden bookmark via the Insert|Bookmark dialogue (check the 'hidden bookmarks' option to see it) and all will be well.
Okay, Macropod, I think I have it now. Thanks a million for your sage advice! I would never have figured this out on my own.

I also found where these hidden bookmarks are coming from. I wasn't creating them directly, but as I was creating and deleting cross-references, Word was creating hidden bookmarks each time.
I found this info from:Bookmarks.ShowHidden property (Word) | Microsoft Docs
"Hidden bookmarks are automatically inserted when cross-references are inserted into the document."

In case it helps someone else with a similar problem, here's my script to delete only hidden bookmarks from a document.
Code:
Sub bhh_deleteHiddenBookmarks()
  ' Delete hidden bookmarks
  
  ' NOTE: Hidden bookmarks may be the result of inserting cross-references into the document, and removing the cross-reference.
  ' As found at: https://docs.microsoft.com/en-us/office/vba/api/word.bookmarks.showhidden
  ' "Hidden bookmarks are automatically inserted when cross-references are inserted into the document."
  ' Hidden bookmark names begin with an underscore _, like _Ref...

  Dim bool_showHiddenBms As Boolean
  Dim bms As bookmarks
  Dim bm As Bookmark
  
  Set bms = ActiveDocument.bookmarks
  
  bool_showHiddenBms = bms.ShowHidden ' Store original state for showing hidden bookmarks
  ' This option is a checkbox from Insert > Bookmark within Word.

  ' Ensure show hidden bookmarks is turned on for this script.
  bms.ShowHidden = True

  ' Loop through all bookmarks, delete hidden ones.
  For Each bm In bms
    If Left(bm.Name, 1) = "_" Then ' If the first character of .Name is an underscore,
      Debug.Print ("Deleting hidden bookmark: " & bm.Name)
      bm.Delete
    End If
  Next bm

  ' Set hidden bookmark option back to starting state
   bms.ShowHidden = bool_showHiddenBms

  Exit Sub
End Sub ' bhh_deleteHiddenBookmarks
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble removing cross-references Trouble with Bulk Removing Unusual Footnotes CrossReach Word 3 06-25-2019 03:00 PM
About Cross-references mohsen.amiri Word 1 01-19-2017 10:35 AM
Convert manual cross references in footnotes to other footnotes to automatic cross references ghumdinger Word VBA 7 11-20-2014 11:47 PM
Trouble removing cross-references Cross-References acolussi Word 9 05-16-2013 02:11 AM
Trouble removing cross-references Trouble Removing Password cure4glass Word 1 02-17-2012 07:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft