![]() |
#3
|
|||
|
|||
![]()
macropod,
Thanks for your response. I going to attach a document that will demo what code I am using to read the values. In this document I have created the bookmark and text box manually and am only reading and attempting to compare the values through code. I was not able to upload the .docm docment. so here is the code from Macro1: Code:
Dim shp As Shape Dim strKeyInfo As String Dim strText As String strKeyInfo = ActiveDocument.Bookmarks("Record").Range.Text For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then shp.Select strText = shp.TextFrame.TextRange.Text If strKeyInfo = strText Then MsgBox "Values Match!" Else MsgBox "Values Do Not Match!" End If End If Next shp Below is the code that I am using to update the bookmark: Code:
Dim strKey As String strChar1 = Me.cboKeyList If Me.cboKeyModifier > "" Then strChar2 = Me.cboKeyModifier Else strChar2 = "" End If strChar3 = Me.cboMajMin strKey = strChar1 & strChar2 & " " & strChar3 UpdateBookmark "Key", strKey Code:
Sub UpdateBookmark(BookmarkToUpdate As String, TextToUse As String) Dim BMRange As Range Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range BMRange.Text = TextToUse ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange End Sub Code:
strKeyInfo = ActiveDocument.Bookmarks("Key").Range.Text If CheckForDesignatedKey(strKeyInfo) = False Then Code:
Public Function CheckForDesignatedKey(sKeyToFind As String) As Boolean 'returns true if key is found in any textbox Dim shp As Shape, strText As String CheckForDesignatedKey = False For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then shp.Select strText = shp.TextFrame.TextRange.Text If sKeyToFind = strText Then CheckForDesignatedKey = True End If End If Next shp End Function When I run my code and display the returned values from my variables in the immediate code window they both appear to have exactly the same values. I keep thinking that I am just missing something. I appreciate your attempting to help. Please take a look at the attached document and the code in Macro1. Hopefully you will see where the problem is. Byron |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
micko1 | Word VBA | 10 | 11-05-2013 04:42 PM |
![]() |
Amapola188 | Word VBA | 3 | 07-12-2012 05:16 PM |
Repeating Bookmark Text | BECKTHOMO | Word | 1 | 03-27-2012 08:34 PM |
![]() |
skarden | Word | 1 | 12-12-2011 10:39 PM |
![]() |
hklein | Word VBA | 4 | 08-10-2011 04:33 AM |