| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic |
| Version: | 1.0 |
| Released: | August 19, 2005 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control ActiveX with Visual Basic |
| Download code: | tx_sample_frame_replace.zip |

One of the main advantages of text frames is the ability to handle each one of them separately. Therefore, it is possible to search for a string in a specific text frame only.
To search for all instances of a string in the main text and all inserted text frames, you just have to loop through all text frames. The following code snippet illustates how to loop through all text frames, using the ObjectNext method:
Do tfID = tx.ObjectNext(i, &H20) If tfID = 0 Then Exit Do Else tx.TextFrameSelect (tfID) count = count + findReplaceText(text, replaceWith) tx.TextFrameSelect -1 End If i = i + 1 Loop
The findReplaceNext function simply uses the Find method to replace all instances of the string in the document. In the sample, our function additionally returns the number of replaced instances.
At least a trial version of TX Text Control ActiveX 12.0 and Visual Basic 6.0 is required to start the sample application.