View Single Post
 
Old 06-09-2014, 09:13 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

If you have Option Explicit at the top of your code pane you should be getting a “Compile Error” variable not defined on ContentControl.If you don’t then you must be getting a run-time error “424” on the If .Title = “Grade” Then line.

That, or there is more to your code than meets to the eye.

You mention bookmark BM2 in your post but there is no reference to a bookmark named “BM2” or anything else related to a bookmark in your code.


Code:
Private Sub Paragraph_Addition()
Dim strDetails As String
Dim oCC As ContentControl
Dim oRng As Range
  Set oCC = ActiveDocument.SelectContentControlsByTitle("Grade").Item(1)
    Select Case oCC.Range.Text
      Case "LOW"
        strDetails = "Please delete all content for Benchmark team."
      Case Else
        strDetails = vbNullString
    End Select
    'Write to bookmark
    If ActiveDocument.Bookmarks.Exists("BM2") Then
      Set oRng = ActiveDocument.Bookmarks("BM2").Range
      oRng.Text = strDetails
      ActiveDocument.Bookmarks.Add "BM2", oRng
    End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote