View Single Post
 
Old 12-30-2014, 11:27 AM
ptmuldoon ptmuldoon is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default Looping/Update BookMark Crashes.

I'm working to create a small script that will 'reset' my bookmarks back to default comments. However, Word keeps crashing each time it attempts to run and I can't seem to figure out why.

This is the sample code, I'm currently working with.
Code:
Sub ResetBookMarks()
    Dim BMName, DefaultComment As String
    Dim oRng As Word.Range
    
    DefaultComment = "XXXXXX"

    For Each Bmk In ActiveDocument.Bookmarks    
        'MsgBox Bmk.Name
        BMName = Bmk.Name
        Set oRng = ActiveDocument.Bookmarks(Bmk.Name).Range
        oRng.Text = ActiveDocument.Bookmarks(Bmk.Name).Range.Text & "Some text here."
        ActiveDocument.Bookmarks.Add BMName, oRng
    Next
    
    ActiveDocument.Bookmarks.ShowHidden = True
    ActiveWindow.View.ShowBookmarks = False
End Sub
FYI.. I'm mainly learned the above so far from Greg Maxey's MVP help here.
http://gregmaxey.com/word_tip_pages/..._bookmark.html
Reply With Quote