![]() |
|
#1
|
|||
|
|||
|
I would like to go through my word document one line at a time and at the end of each line there needs to be a paragraph character "^p". If there is not one I would like VBA to insert one.
|
|
#2
|
||||
|
||||
|
Really? Can you explain why you want to turn your wrapping paragraph text into discrete paragraphs?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#3
|
|||
|
|||
|
I am needing to copy and paste my word document into excel while retaining the same format and spacing. Excel does not recognize wrapping paragraph text but does recognize discrete paragraphs.
|
|
#4
|
||||
|
||||
|
You can't retain the Word formatting that way, though you could enable text wrapping within Excel. Moreover, a document that's got complex formatting (e.g. numbered, bulleted, indented, justified paragraphs) would be totally screwed up for copy/paste purposes by what you're suggesting. Perhaps you should consider pasting the document into Excel as an embedded object.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
Quote:
The purpose of this is to use excel to quickly draw a table in Revit with notes formatted in Word. Unfortunately Autodesk has not made Revit friendly to bringing in large blocks of notes from Word. If there is a simple code for my original post please let me know. |
|
#6
|
||||
|
||||
|
Evidently, you haven't tried with using a Word document with numbered or bulleted paragraphs, paragraphs with first-line indents, justified text, etc., etc.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
If you're just looking to put each sentence on a single line this will work assuming each sentence ends with a period and then a space and no numbered or bulleted paragraphs like macropod pointed out. I know there's a way to include all punctuation you would normally see at the end of a sentence but I don't know it.
Code:
Sub FindReplaceX2()
Selection.WholeStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ". "
.Replacement.Text = ".^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
Selection.WholeStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^13{2,}"
.Replacement.Text = "^p"
.Forward = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub
|
|
#8
|
||||
|
||||
|
That will give false results where abbreviations are used ...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#9
|
|||
|
|||
|
Yes I thought about that after. - Dr. Mr. etc. Thanks
|
|
#10
|
||||
|
||||
|
Besides which, even if one were to break paragraphs into lines as the OP suggests, copying & pasting the result into Excel would cause each line to be put in successive cells, not in the same cell.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#11
|
|||
|
|||
|
I thought that's what he wanted? each sentence in a cell?
I tried putting "[.;:’””"/\!\*\?\\] " didn't work in macro but works in find replace function? |
|
#12
|
||||
|
||||
|
That's hardly consistent with:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#13
|
|||
|
|||
|
Yes you're right as usual. I read the words and pictured something completely different. lol Sorry
|
|
#14
|
||||
|
||||
|
Quote:
I still don't see the problem, if I copy Word content and go to Excel and choose Paste Special > Microsoft Word Document Object (as you said you are doing) then the content appears with the same line wraps that the Word document had.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#15
|
||||
|
||||
|
Even soft returns in Word result in the pasted content in Excel going to separate cells.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| insert, paragraph character |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to insert paragraph character after every 500 characters?
|
aditya_bokade | Word VBA | 28 | 11-13-2021 10:48 PM |
Replace a character only if it is at the beginning of the paragraph.
|
donpopo | Word | 2 | 11-11-2018 11:32 PM |
| Add paragraph return between two specific character | jeffreybrown | Word | 2 | 03-30-2017 02:45 PM |
Can't get rid of Chinese character when inserting citation
|
slavrenz | Word | 13 | 05-13-2015 11:47 AM |
Replace paragraph-marks (line-breaks) in tables with a character-string
|
Aztec | Word VBA | 2 | 04-02-2013 10:52 PM |