![]() |
#1
|
|||
|
|||
![]()
Word 2010
Document is made up of multiple sections. I need to verify that a string is in the first section. How do I search for a text value in the first section of the document? |
#2
|
||||
|
||||
![]()
You could use code like:
Code:
Sub Demo() With ActiveDocument.Sections.First.Range.Find .Text = "My Text" .ClearFormatting .Replacement.ClearFormatting .Format = False .Forward = True .Wrap = wdFindStop .MatchWildcards = True .Execute If .Found Then MsgBox .Text & vbCr & "found in Section 1.", vbInformation Else MsgBox .Text & vbCr & "NOT found in Section 1", vbCritical End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
How would the procedure change if I was looking in section 2?
|
#4
|
||||
|
||||
![]()
Change '.First' to (2).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Thank you for taking the time to answer my question. I appreciate you sharing your expertise.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
New Daddy | Word | 6 | 02-03-2014 07:09 PM |
![]() |
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
Excel Fomula to search for a string and display value from different column | zeeshanbutt | Excel | 1 | 07-29-2012 12:48 AM |
![]() |
francis | Excel | 1 | 10-06-2011 01:43 PM |
![]() |
dfinch | Word VBA | 2 | 06-09-2011 05:10 AM |