View Single Post
 
Old 07-30-2014, 05:41 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
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

As coded, unless your 'Record' bookmarked range includes a terminating paragraph break, the match will fail because the textbox text necessarily includes one. On the assumption that terminating paragraph breaks in both the bookmarked range and the textbox should be excluded from the comparison, you could use:
Code:
Dim shp As Shape, strKeyInfo As String, strText As String, Rng As Range
With ActiveDocument
  Set Rng = .Bookmarks("Record").Range
  With Rng
    Do While .Characters.Last = vbCr
      .End = .End - 1
      If .Start = .End Then Exit Do
      Loop
    strKeyInfo = .Text
  End With
  For Each shp In .Shapes
    With shp
      If .Type = msoTextBox Then
        Set Rng = .TextFrame.TextRange
        With Rng
          Do While .Characters.Last = vbCr
            .End = .End - 1
            If .Start = .End Then Exit Do
            Loop
          strText = .Text
        End With
        If strKeyInfo = strText Then
          MsgBox "Values Match!"
        Else
          MsgBox "Values Do Not Match!"
        End If
      End If
    End With
  Next
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote