View Single Post
 
Old 08-24-2012, 05:20 PM
netchie netchie is offline Windows XP Office 2007
Novice
 
Join Date: Jun 2011
Posts: 24
netchie is on a distinguished road
Default

The problem is I need to use it in Word doc and not convert it to others. Data came from Crystal by the way.

Thi sis what I have but what I need is to remove lines that have "No Color" but with zero values. If they have 1 or other values, i should not be removed. Also, as I've said i it has next row(s) data, it should be removed as well BUT only with zero values.

What I have is this only for No Color:
Code:
'Remove the No Color line
Sub NoCorrelateRemove()
Dim lineRange As Range
Dim searchRange As Range
'Search the entire document
Set searchRange = ActiveDocument.Content
Do
  'Find the No Color line
  With searchRange.Find
    .ClearFormatting
    .Wrap = wdFindStop
    .Forward = True
    .Text = "No Color"
    .Execute
    If Not .Found Then
      Exit Do
    End If
  End With
  'create a range that covers this entire line
  Set lineRange = ActiveDocument.Range(searchRange.Start = 1, searchRange.End = 5)
  lineRange.Expand wdParagraph
  lineRange.Delete
Loop
End Sub

Last edited by macropod; 08-24-2012 at 05:32 PM. Reason: Added code tags & formatting
Reply With Quote