![]() |
#5
|
|||
|
|||
![]()
Hi there.
Maybe you can start with something like: (save/close any other files you're using before testing macros, backup your original file before doing any modification, test in a throwaway copy of your file) Code:
Sub Find_paragraph_with_string() Dim x As Integer, oDoc, y As Integer Set oDoc = ActiveDocument For x = oDoc.Sections.Count To 1 Step -1 With oDoc.Sections(x).Range For y = 1 To .Paragraphs.Count If InStr(.Paragraphs(y).Range.Text, "Hello") > 0 Then MsgBox "Hello! I'm in the " & y & " paragraph of the " & x & " section!" Next y End With Next x End Sub Sub Find_table_cell_with_string() Dim x As Integer, oDoc, y As Integer, oCel Set oDoc = ActiveDocument For x = oDoc.Sections.Count To 1 Step -1 With oDoc.Sections(x).Range If .Tables.Count > 0 Then For y = 1 To .Tables.Count For Each oCel In .Tables(y).Range.Cells If Left(oCel.Range.Text, Len(oCel.Range.Text) - 2) = "Hi!" Then MsgBox "Found!" Next oCel Next y End If End With Next x End Sub
__________________
Backup your original file before doing any modification. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
hils0590 | OneNote | 3 | 12-31-2014 10:35 AM |
![]() |
Iain | Outlook | 1 | 02-20-2012 10:30 PM |