Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2015, 09:16 AM
drfawad drfawad is offline How to automatically place text after specified paragraphs Windows XP How to automatically place text after specified paragraphs Office 2007
Novice
How to automatically place text after specified paragraphs
 
Join Date: Sep 2015
Posts: 1
drfawad is on a distinguished road
Default How to automatically place text after specified paragraphs

I have ms word document which has thousands of MCqs, i want to place some specific text after each MCQ (paragraph) as its very difficult to do it manually.



Here is an example:

This is the original document:

http://s29.postimg.org/oc92oeqw7/image.jpg

This is what i want to do:

http://s7.postimg.org/8ohm9jafv/image.jpg
Reply With Quote
  #2  
Old 09-12-2015, 07:59 PM
DougMVP DougMVP is offline How to automatically place text after specified paragraphs Windows 7 32bit How to automatically place text after specified paragraphs Office 2010 32bit
Advanced Beginner
 
Join Date: Nov 2013
Posts: 50
DougMVP will become famous soon enough
Default

Is there an empty paragraph in the space between the e. paragraph and the following text?

Also, do you want the Red line as well as the text "Ans."

If there is an empty paragraph in the space, the following should do what you want:

Code:
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
    Do While .Execute(FindText:="^p^p", MatchWildcards:=False, Forward:=True, Wrap:=wdFindStop) = True
        With Selection
            .Collapse wdCollapseEnd
            With .Borders(wdBorderTop)
                .LineStyle = wdLineStyleSingle
                .LineWidth = wdLineWidth450pt
                .Color = wdColorRed
            End With
            .InsertBefore "Ans." & vbCr
            .Collapse wdCollapseEnd
        End With
    Loop
End With
Reply With Quote
  #3  
Old 09-12-2015, 08:34 PM
macropod's Avatar
macropod macropod is offline How to automatically place text after specified paragraphs Windows 7 64bit How to automatically place text after specified paragraphs Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

It seems to me you could not this with nothing more complicated than a wildcard Find/Replace, where:
Find = ^13[0-9]{1,}.
Replace = ^pAns.^&
Or, if you also want the solid line above 'Ans.', you could first create such a paragraph, then cut it to the clipboard and use:
Find/Replace, where:
Find = (^13)([0-9]{1,}.)
Replace = \1^c\2
Another way - and probably the best if you want the solid line - is to define a paragraph Style for it and use:
Find = ^13[0-9]{1,}.
Replace = ^pAns.^&
then
Find = Ans.^13
Replace = ^&
where the 'Replace' expression also includes the Style name.

None of this requires a macro, though the Find/Replace could be turned into one, and would be much faster on a long document and more reliable in any length document than looping through all the paragraphs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Text To Place holder phamh PowerPoint 0 03-03-2015 08:11 AM
How to automatically place text after specified paragraphs editing a number/text at one place and changes taking place wherever it appears anurag.butoliya Word 1 06-14-2014 06:27 PM
Help please: Automatically pulling info out of one document and place in others. qwerty11 Word 2 06-25-2013 07:49 AM
How to automatically place text after specified paragraphs Automatically generating paragraphs with form data mkellar Word 1 03-22-2013 10:10 PM
format cells to automatically place quotes around text dirtleg Excel 1 09-16-2008 01:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:32 PM.


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