Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-30-2014, 05:41 AM
macropod's Avatar
macropod macropod is offline Compare text from Bookmark with text from Text box Windows 7 32bit Compare text from Bookmark with text from Text box Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,342
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare text from Bookmark with text from Text box VBA to input / clear text from a Bookmark micko1 Word VBA 10 11-05-2013 04:42 PM
Compare text from Bookmark with text from Text box Open header to insert text into bookmark Amapola188 Word VBA 3 07-12-2012 05:16 PM
Repeating Bookmark Text BECKTHOMO Word 1 03-27-2012 08:34 PM
Compare text from Bookmark with text from Text box Word 2003 - IncludeText Does Not Include Bookmark Text if in a Form Text Control skarden Word 1 12-12-2011 10:39 PM
Compare text from Bookmark with text from Text box delete all bookmark text hklein Word VBA 4 08-10-2011 04:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:36 PM.


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