Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2018, 02:54 PM
puff puff is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2013
Advanced Beginner
Delete the graph based on its character number
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Default 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).
Reply With Quote
  #2  
Old 02-26-2018, 04:49 PM
macropod's Avatar
macropod macropod is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 02-27-2018, 11:39 PM
puff puff is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2013
Advanced Beginner
Delete the graph based on its character number
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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
Thanks! This is very neat! Just a note that the last line should be Replace = ^13
Reply With Quote
  #4  
Old 02-27-2018, 11:40 PM
macropod's Avatar
macropod macropod is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by puff View Post
Just a note that the last line should be Replace = ^13
No, it shouldn't! You will get very strange document behaviour if you do that.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-28-2018, 12:38 AM
puff puff is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2013
Advanced Beginner
Delete the graph based on its character number
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
No, it shouldn't! You will get very strange document behaviour if you do that.
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.
Reply With Quote
  #6  
Old 02-28-2018, 03:00 AM
eduzs eduzs is offline Delete the graph based on its character number Windows 10 Delete the graph based on its character number Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 260
eduzs is on a distinguished road
Default

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
Backup your original files before do any modifications or test, test before use, use at your own.
Reply With Quote
  #7  
Old 03-12-2018, 04:55 PM
macropod's Avatar
macropod macropod is offline Delete the graph based on its character number Windows 7 64bit Delete the graph based on its character number Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by eduzs View Post
You can try a VBA macro code like that:
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]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete the graph based on its character number count a number of cells based on the beginning of a order number Kubi Excel 2 08-06-2017 08:54 PM
Delete the graph based on its character number Delete Character on Single Line Only Tye30 Word VBA 8 04-20-2017 08:40 PM
Delete the graph based on its character number 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:22 AM.


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