![]() |
#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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
PRA007 | Word VBA | 2 | 02-19-2016 12:52 AM |
![]() |
PRA007 | Word VBA | 1 | 12-02-2015 04:22 AM |
![]() |
Andy Pilkington | Word | 2 | 10-10-2014 12:36 AM |
![]() |
Smallweed | Word VBA | 4 | 08-19-2014 07:21 AM |
![]() |
radman154 | Word Tables | 1 | 03-25-2011 12:04 AM |