Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 08-24-2012, 05:20 PM
netchie netchie is offline Need VBA For Macro On How To Remove Specific Words Windows XP Need VBA For Macro On How To Remove Specific Words Office 2007
Novice
Need VBA For Macro On How To Remove Specific Words
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need VBA For Macro On How To Remove Specific Words Macro to replace one specific heading style with another ubns Word VBA 44 09-04-2012 08:17 PM
can I run a macro when I open a specific doc. shreked Word 8 01-12-2012 03:36 AM
Need VBA For Macro On How To Remove Specific Words Macro for highlighting specific number of words icsjohn Word VBA 2 12-07-2011 06:44 PM
Need VBA For Macro On How To Remove Specific Words Macro to remove MacroButtons ilkks Word VBA 3 05-22-2011 11:03 PM
Remove specific recipients while replying to all McFerra Outlook 0 12-22-2010 10:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft