View Single Post
 
Old 09-24-2018, 10:44 AM
ashalles135 ashalles135 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2018
Posts: 4
ashalles135 is on a distinguished road
Default Word macro to insert text at the beginning of paragraph but skip tables

Hi,

I am trying to modify the following macro to skip all tables in a document.

I tried to add "tables" with the rest of the text that is ignored, but it still puts a "(U) " in each cell.

Our text gets dumped out of another program and everything is styled "Normal"... including the tables. If I style the table text, then all the dollar amounts become left justified, which is time-intensive to fix.

Does anyone have any suggestions?


Code:
With ActiveDocument.Content.Find
    .ClearFormatting
    .Style = wdStyleNormal
    Do While .Execute(Forward:=True, Format:=True) = True
      With .Parent
  If Left(.Text, 1) = vbCr Or Left(.Text, 1) = " " Or Left(.Text, 1) = chr(12) Or (wdWithInTable) Then
          'do nothing
        Else
          .InsertBefore "(U) "
        End If
        
        If .End = ActiveDocument.Content.End Then
          Exit Do
        Else
          .Move unit:=wdParagraph, Count:=1
        End If
      End With
    Loop
  End With
End Sub

Last edited by macropod; 09-24-2018 at 05:17 PM. Reason: Added code tags & formatting
Reply With Quote