Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2014, 09:17 AM
donaldadams1951 donaldadams1951 is offline Search first section for specific string... Windows XP Search first section for specific string... Office 2010 32bit
Advanced Beginner
Search first section for specific string...
 
Join Date: Dec 2013
Location: San Francisco Bay Area
Posts: 37
donaldadams1951 is on a distinguished road
Default Search first section for specific string...

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?
Reply With Quote
  #2  
Old 03-14-2014, 11:15 AM
macropod's Avatar
macropod macropod is offline Search first section for specific string... Windows 7 32bit Search first section for specific string... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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]
Reply With Quote
  #3  
Old 03-14-2014, 11:19 AM
donaldadams1951 donaldadams1951 is offline Search first section for specific string... Windows XP Search first section for specific string... Office 2010 32bit
Advanced Beginner
Search first section for specific string...
 
Join Date: Dec 2013
Location: San Francisco Bay Area
Posts: 37
donaldadams1951 is on a distinguished road
Default Just for future reference...

How would the procedure change if I was looking in section 2?
Reply With Quote
  #4  
Old 03-14-2014, 11:21 AM
macropod's Avatar
macropod macropod is offline Search first section for specific string... Windows 7 32bit Search first section for specific string... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Change '.First' to (2).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-14-2014, 11:24 AM
donaldadams1951 donaldadams1951 is offline Search first section for specific string... Windows XP Search first section for specific string... Office 2010 32bit
Advanced Beginner
Search first section for specific string...
 
Join Date: Dec 2013
Location: San Francisco Bay Area
Posts: 37
donaldadams1951 is on a distinguished road
Default Thank you...

Thank you for taking the time to answer my question. I appreciate you sharing your expertise.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search first section for specific string... Deleting section break and retaining section properties New Daddy Word 6 02-03-2014 07:09 PM
Search first section for specific string... Way to search for a string in text file, pull out everything until another string? 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
Search first section for specific string... Convert numbers to a specific text string francis Excel 1 10-06-2011 01:43 PM
Search first section for specific string... Printing specific section dfinch Word VBA 2 06-09-2011 05:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft