#1
|
|||
|
|||
Delete the graph based on its character number
Hi all. Is it possible to delete all the graphs whose length is smaller than a certain extent? Like delete all the paragraphs that only has 3 characters (not 3 words).
|
#2
|
||||
|
||||
You don't even need a macro for that - just an ordinary Find/Replace. For example, to delete paragraphs containing exactly three characters (in addition to the paragraph break), use:
Find = ^p^?^?^?^p Replace = ^p or you could use a wildcard Find/Replace with: Find = ^13[!^13]{3}^13 Replace = ^p To delete paragraphs containing up to three characters (in addition to the paragraph break), use a wildcard Find/Replace with: Find = ^13[!^13]{1,3}^13 Replace = ^p
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Quote:
|
#4
|
||||
|
||||
No, it shouldn't! You will get very strange document behaviour if you do that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Sorry. Yeah, you're right. I tested it on a piece of manually typed very simple text and I did notice that will cause some change in the format.
|
#6
|
|||
|
|||
You can try a VBA macro code like that:
Code:
Sub x() Dim MyPara As Paragraph For Each MyPara In ActiveDocument.Paragraphs If MyPara.Range.Characters.Count <= 4 Then MyPara.Range.Delete Next MyPara End Sub |
#7
|
||||
|
||||
A wildcard Find/Replace macro would be far faster - even a recorded one would be faster than your code.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
count a number of cells based on the beginning of a order number | Kubi | Excel | 2 | 08-06-2017 08:54 PM |
Delete Character on Single Line Only | Tye30 | Word VBA | 8 | 04-20-2017 08:40 PM |
Delete starting number *) and delete Unneeded data in series | frustrated teacher | Word VBA | 5 | 12-07-2014 06:53 PM |
first character NOT Alpha numeric or Tilde (~) delete. | ksridh | Word VBA | 5 | 03-17-2014 12:45 AM |
graph changes number when losing embedded link | Alaska1 | Excel | 0 | 08-14-2013 11:31 AM |