Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT
Sub Add_Table_Bookmarks() Dim tbl As Table Dim b As Integer Dim rng As Range Dim Bookmark1 As Variant Dim Bookmark2 As Variant If MsgBox("Would you like to create bookmarks in certain cells of all the tables?" & vbCrLf & vbCrLf & _ "These bookmarks form the basis for TOC items!" & vbCrLf & _ "Normally the MOH-Codes and Set Descriptions are the ones to be bookmarked", vbYesNo + vbQuestion, "Create bookmarks in table!") = vbNo Then Exit Sub End If Bookmark1 = InputBox("Please indicate the first cell to be bookmarked!", "first cell to be bookmarked") If Bookmark1 = "" Then Exit Sub Bookmark2 = InputBox("Please indicate the second to be bookmarked!", "second cell to be bookmarked") If Bookmark2 = "" Then Exit Sub b = 1 With ActiveDocument For Each tbl In .Tables ' new requirement: the macro should only run on table 5, 13, 19, 23, 27, 44, 54, 73 Set rng = tbl.Cell(2, Bookmark1).Range 'first cell rng.MoveEnd wdCharacter, -1 .Bookmarks.Add ("bookmark_" & b), rng Set rng = tbl.Cell(2, Bookmark2).Range 'fourth cell rng.MoveEnd wdCharacter, -1 .Bookmarks.Add ("bookmark_" & b + 1), rng b = b + 2 Next tbl End With End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.