Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-15-2019, 10:20 PM
gmayor's Avatar
gmayor gmayor is offline REf Fields show Bookmark whole cell when Bookmark is created by code. Windows 10 REf Fields show Bookmark whole cell when Bookmark is created by code. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You are overcomplicating this. To bookmark the values in Column 3 with the names from Column 4: ....(see also attached)

Code:
Sub Mcr_Set_Bookmarks()
Dim BKMkName As String
Dim BkmkRange As Range
Dim oCell As Range
Dim rV As Integer
    For rV = 2 To ActiveDocument.Tables(1).Rows.Count
        Set oCell = ActiveDocument.Tables(1).Cell(rV, 4).Range
        oCell.End = oCell.End - 1 'Omit cell end character
        BKMkName = oCell.Text
        Set BkmkRange = ActiveDocument.Tables(1).Cell(rV, 3).Range
        BkmkRange.End = BkmkRange.End - 1 'Omit cell end character
        'Add the bookmark to the cell content range
        ActiveDocument.Bookmarks.Add Range:=BkmkRange, Name:=BKMkName
    Next rV
    Set oCell = Nothing
    Set BkmkRange = Nothing
End Sub
Attached Files
File Type: docm Automated_Sttements_Working_v_4.1.docm (83.3 KB, 8 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I code bookmark globally for different template? Yong Xiang Word VBA 17 02-06-2019 01:09 PM
REf Fields show Bookmark whole cell when Bookmark is created by code. Field Code: Show a value only if bookmark is not empty Cosmo Word 7 08-24-2018 01:46 PM
Bookmark will not show/hide based on CC Checkbox lord_kaiser Word VBA 1 04-17-2018 01:19 AM
REf Fields show Bookmark whole cell when Bookmark is created by code. Bookmark - add two merge fields dfin Word VBA 5 09-06-2016 10:08 PM
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:25 AM.


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