Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 11-04-2015, 03:06 AM
PRA007's Avatar
PRA007 PRA007 is offline How to paste as a single para from clipboard having multiple paragraph Windows 7 32bit How to paste as a single para from clipboard having multiple paragraph Office 2010 32bit
Competent Performer
How to paste as a single para from clipboard having multiple paragraph
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Thanks for answer.
Instead of clicking I copy pasted link in google and it lead me to.
http://www.vbaexpress.com/forum/show...raphs-from-PDF
Changed it the way you descrived. Solved my problem

Code:
Sub PasteCleanUpText() 
     
    Application.ScreenUpdating = False 
     
    Dim oRng As Range 
    Set oRng = Selection.Range 
    oRng.Paste 
     'oRng = Replace(oRng, Chr(13), " ")
     
    oRng.ParagraphFormat.Reset 
    oRng.Font.Reset 
     
    With oRng.Find 
        .ClearFormatting 
        .Replacement.ClearFormatting 
        .Forward = True 
        .Wrap = wdFindStop 
        .Format = False 
        .MatchAllWordForms = False 
        .MatchSoundsLike = False 
        .MatchWildcards = True 
         
         'Replace single paragraph breaks with a space
        .Text = "([!^13])([^13])([!^13])" 
        .Replacement.Text = "\1 \3" 
        .Execute Replace:=wdReplaceAll 
         
         'Replace all double spaces with single spaces
        .Text = "[ ]{2,}" 
        .Replacement.Text = " " 
        .Execute Replace:=wdReplaceAll 
         
         'Delete hypens in hyphenated text formerly split across lines
         '.Text = "([a-z])-[ ]{1,}([a-z])"
         '.Replacement.Text = "\1 \2" 'formerly \1\2
         '.Execute Replace:=wdReplaceAll
         
         'Limit paragraph breaks to one per 'real' paragraph.
        .Text = "[^13]{1,}" 
        .Replacement.Text = "^p" 
        .Execute Replace:=wdReplaceAll 
         
    End With 
     
    Application.ScreenUpdating = True 
     
End Sub
Reply With Quote
 

Tags
word 2010, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to paste as a single para from clipboard having multiple paragraph How to select and copy to clipboard an entire document except for a paragraph and keep formatting TD_123 Word VBA 7 06-16-2015 03:30 PM
How can I temporarily break a 3 column format in order to type a single column paragraph William P Word 1 01-04-2015 06:40 PM
Controlling Widows (single-word lines at the end of a paragraph) downtownbooks Word 2 12-09-2014 03:57 PM
How to paste as a single para from clipboard having multiple paragraph Get para no where txt is found, and move text to end of paragraph using Word 201 marceepoo Word VBA 2 12-20-2012 11:42 AM
How to paste as a single para from clipboard having multiple paragraph A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline kyjac85 Word VBA 13 09-20-2012 05:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:09 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