![]() |
|
|
|
#1
|
||||
|
||||
|
Since I got nice answer at https://www.msofficeforums.com/word-...sing-word.html my life become easier. My every task is based on this template since.
Code:
Sub template()
'From https://www.msofficeforums.com/word-vba/28819-extracting-data-excel-document-using-word.html
Application.ScreenUpdating = False
Set wdDoc = ActiveDocument
With wdDoc.Range
For Each Tbl In .Tables
With Tbl
For i = 1 To .Rows.Count
With .Cell(i, 2).Range.Paragraphs(1).Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "String"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
If .Find.Found Then
'Do whatever you want.
End If
End With
Next
End With
Next
End With
End Sub
|
|
#2
|
||||
|
||||
|
Delete the loop and set the table to Selection.Tables(1)
Code:
Dim Tbl as table Set Tbl = Selection.Tables(1)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
||||
|
||||
|
Or you could just delete:
Set wdDoc = ActiveDocument and change: wdDoc to: Selection
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#4
|
||||
|
||||
|
Great. That simple!
|
|
| Tags |
| word vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Working with Selection.range.
|
PRA007 | Word VBA | 2 | 02-19-2016 12:52 AM |
Working with word tables.
|
PRA007 | Word VBA | 1 | 12-02-2015 04:22 AM |
Header Rows in Tables Not Working
|
Andy Pilkington | Word | 2 | 10-10-2014 12:36 AM |
Selection.EndKey not working in 2010
|
Smallweed | Word VBA | 4 | 08-19-2014 07:21 AM |
working with excel tables in MS word
|
radman154 | Word Tables | 1 | 03-25-2011 12:04 AM |