#1
|
||||
|
||||
How to paste as a single para from clipboard having multiple paragraph
I have in clipboard text having page breaks
Quote:
Quote:
Is there any inbuilt function for this? |
#2
|
||||
|
||||
There is no paste function for what you want. There are macros for cleaning up text pasted from websites, emails & PDFs, but those are generally designed to work with large blocks of text. If you're interested in that kind of thing, see: https://www.msofficeforums.com/word/...html#post24698
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
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 |
#4
|
||||
|
||||
As you will see from where you got that code, there were problems with it - and I provided advice about that. The code in the link in post #2 is superior.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
||||
|
||||
ohh. It took some time to realize way I always lost the formatting.
for me my original document contains subscript and superscript etc. but while using above code removes it. Thanks for suggestion. |
#6
|
||||
|
||||
The code in the link I posted doesn't remove such formatting...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
||||
|
||||
As This has solved my problem, can be marked as solved.
|
#8
|
||||
|
||||
You can mark threads as solved yourself, via the 'Thread Tools' dropdown.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
||||
|
||||
Oh!!!. I thought....
I will do that from now onward. |
Tags |
word 2010, word vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |
A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline | kyjac85 | Word VBA | 13 | 09-20-2012 05:00 PM |