#1
|
|||
|
|||
Word VBA: Continuous Find???
Views: 10 Size: 15.8 KB">FindTillDocumentEnd.docx I wonder how I can continuously find the manual line break after the strings "ordered by ministers." I used "^013" but failed to find it. And another problem is: How can I use Code:
ActiveDocument.Content.Find like what we do in Find And Replace? |
#2
|
||||
|
||||
Hi tinfanide,
It's not entirely clear what you're after. If you're trying to delete the empty paragraph following "ordered by ministers.", you could use a macro like the following. This macro deletes all tabs, leading & trailing spaces, linefeeds and empty paragraphs (including those with spaces only) from all cells in all tables (including nested tables) in the active document, without otherwise affecting the formatting of text in the cells. Code:
Sub TableCleaner() Application.ScreenUpdating = False Dim Tbl As Table, Cel As Cell, Rng As Range, Para As Paragraph With ActiveDocument For Each Tbl In .Tables With Tbl.Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False .Text = "[^t]" .Replacement.Text = " " .Execute Replace:=wdReplaceAll .Text = "[ ]{2,}" .Replacement.Text = " " .Execute Replace:=wdReplaceAll .Text = "[^l^13]{1,}" .Replacement.Text = "^p" .Execute Replace:=wdReplaceAll .Text = "[^13 ]{2,}" .Replacement.Text = "^p" .Execute Replace:=wdReplaceAll End With For Each Cel In Tbl.Range.Cells Set Rng = Cel.Range Rng.End = Rng.End - 1 If Rng.Start <> Rng.End Then For Each Para In Rng.Paragraphs With Para.Range If .Characters.Count = 1 And .Cells.Count = 1 Then .Characters.First = vbNullString On Error Resume Next If .End = .Cells(1).Range.End Then .Characters.Last.Previous.Delete End If If .End = Rng.End Then Rng.Characters.Last = vbNullString End With Next End If Next Next End With Set Rng = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Learnt a lot from your example,
especially the use of Range.End and vbNullString Thank you. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bad view when using Find and Find & Replace - Word places found string on top line | paulkaye | Word | 4 | 12-06-2011 11:05 PM |
Need continuous audio alert... | oooiooo | Outlook | 1 | 07-27-2011 10:52 AM |
Continuous Loop | cksm4 | Word | 6 | 01-06-2011 09:03 PM |
How do you imbed a continuous play mp3 into a ppt | Joe Damore | PowerPoint | 2 | 09-15-2010 11:13 PM |
continuous sound | boutells | PowerPoint | 2 | 11-27-2009 12:06 AM |