Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-23-2018, 02:38 PM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default Paging [keep lines together; keep with next]

Hi,
It's my first post!


I need your help please in formatting Multiple Choice Questions.
I want to keep the question and its choices to be together in same page.
Did some google search, tried keep lines together and keep with next; but they didn't work for me. [may be because it considers each choice (level 2) as new paragraph]
Reply With Quote
  #2  
Old 03-23-2018, 04:46 PM
Charles Kenyon Charles Kenyon is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,472
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Set up your numbering following the instructions here:
How to create numbered headings or outline numbering in Ribbon Versions of Word by Shauna Kelly

Use three styles for this.
Use both keep with next and keep lines together, selectively.

1. Question - use both for this style. Level 1 style
a. - d. - use both - those are the level 2 numbering style
e. - use keep lines together but not keep with next. This is a separate style (Level 2a) based on the level 2 style without keep with next.

Modify your styles so that level 1 and 2 styles are both followed by level 2 style. You may want a keyboard shortcut for the level 2a style. Follow the level 2a style with the level 1 style. The level 2a style is for the last answer in the list.
Reply With Quote
  #3  
Old 03-23-2018, 10:12 PM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Got the idea, but! how can I implement this. I have +10,000 questions
Anyway to keep last choice to be of level2a style? doing it manually is really pain
Reply With Quote
  #4  
Old 03-23-2018, 11:19 PM
macropod's Avatar
macropod macropod is offline Paging [keep lines together; keep with next] Windows 7 64bit Paging [keep lines together; keep with next] Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

Perhaps the simplest way to implement this is to apply the 'keep with next' attribute to Styles used for both the questions and their answers, but to have a paragraph in a different Style that doesn't have the 'keep with next' attribute between the last answer and the next question. I wouldn't ordinarily recommend having empty paragraphs but, in this case, it seems the simplest route to an effective solution that's easy to maintain.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-24-2018, 12:06 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Perhaps the simplest way to implement this is to apply the 'keep with next' attribute to Styles used for both the questions and their answers, but to have a paragraph in a different Style that doesn't have the 'keep with next' attribute between the last answer and the next question. I wouldn't ordinarily recommend having empty paragraphs but, in this case, it seems the simplest route to an effective solution that's easy to maintain.
EDIT: sorry didn't read your post well; how can I add empty paragraph after last choice and the question.. (any way to do it quickly; going through +10,000 question one by one is very difficult)
Reply With Quote
  #6  
Old 03-24-2018, 12:54 AM
macropod's Avatar
macropod macropod is offline Paging [keep lines together; keep with next] Windows 7 64bit Paging [keep lines together; keep with next] Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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 could, for example, use Find/Replace to insert an empty paragraph before every question. So, if your questions use the Heading 1 Style, simply do a Find/Replace for that with:
Find Style = Heading 1
Replace = ^p^&
It's a bit trickier to do the rest manually from there for +10,000 questions, but the following macro should take care of the lot:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  If .Characters.Last.Previous <> vbCr Then .InsertAfter vbCr
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = "^p^&"
    .Format = True
    .Style = wdStyleHeading1
    .Forward = True
    .MatchWildcards = False
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
  End With
  If .Characters.First = vbCr Then .Characters.First.Delete
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Text = "[^13]{2,}"
    .Replacement.Text = ""
    .MatchWildcards = True
    .Wrap = wdFindStop
    .Execute
  End With
  Do While .Find.Found
    .Paragraphs.Last.Range.Style = wdStyleNormal
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-24-2018, 01:26 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Wonderful!! Thanks a lot... I did the Find/Replace and the result is:

and the micro did the rest!


I have some curiosity.. can you please explain briefly what does this micro do?

Is it possible to do what you have done without micro? that will be interesting if yes
Reply With Quote
  #8  
Old 03-24-2018, 03:29 AM
macropod's Avatar
macropod macropod is offline Paging [keep lines together; keep with next] Windows 7 64bit Paging [keep lines together; keep with next] Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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 sarah2020 View Post
Wonderful!! Thanks a lot... I did the Find/Replace ...
and the micro did the rest!
You should have used only the macro - as I said, it "should take care of the lot".
Quote:
Originally Posted by sarah2020 View Post
I have some curiosity.. can you please explain briefly what does this micro do?
The macro starts off by inserting an empty paragraph at the end of the document if there isn't already one there. It then does the Find/Replace I described. That produces a pair of consecutive paragraph breaks before any Heading 1 - the last also being in the Heading1 Style (from your description, the preceding one will typically be in the Heading 2 Style). This is followed by another more complicated Find/Replace - which wouldn't be easy to do manually - in which the last in any series of consecutive paragraph breaks is given the 'Normal' Style (which ordinarily won't have the 'keep with next' attribute). That allows your document to create its own page break between questions where a question and all its answer choices won't fit on the same page. Finally, the macro deletes the first character in the document if that character is a paragraph break - something that could be cause by the initial Find/Replace if the document starts with a question.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-24-2018, 02:04 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

I’ve no background on vba at all. But I would love to know how to do the above vba code with find/replace. I faced this similar problem a lot ! Would highly appreciate it
Reply With Quote
  #10  
Old 03-24-2018, 03:37 AM
macropod's Avatar
macropod macropod is offline Paging [keep lines together; keep with next] Windows 7 64bit Paging [keep lines together; keep with next] Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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 sarah2020 View Post
I’ve no background on vba at all. But I would love to know how to do the above vba code with find/replace. I faced this similar problem a lot ! Would highly appreciate it
Find/Replace macros are usually required to handle very specific requirements that can't easily be handled by other means. See, for example, the Cleaning up Text Pasted from Websites, E-mails, PDFs etc. 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/word/...s-e-mails.html. Although that is fairly generic, something so generic can't easily be adapted to situations such as yours. That said, there are many Find/Replace macros you could find by trawling through our Word VBA forum: https://www.msofficeforums.com/word-vba/. You might get some useful ideas from them.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 03-24-2018, 05:31 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Find/Replace macros are usually required to handle very specific requirements that can't easily be handled by other means. See, for example, the Cleaning up Text Pasted from Websites, E-mails, PDFs etc. 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/word/...s-e-mails.html. Although that is fairly generic, something so generic can't easily be adapted to situations such as yours. That said, there are many Find/Replace macros you could find by trawling through our Word VBA forum: https://www.msofficeforums.com/word-vba/. You might get some useful ideas from them.
Thank you very much.
Reply With Quote
  #12  
Old 03-24-2018, 06:33 AM
Charles Kenyon Charles Kenyon is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,472
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Take a look, again, at my original post, which tells you how to do this, without macros.

No empty paragraph is needed or desirable. Generally speaking, empty paragraphs are a bad thing. 2.2 Why you should press Enter only once to end a paragraph

Instead, you can use larger spacing-after paragraph formatting as part of the style for that last answer.
See the macro-free document "Question Styles" on my downloads page.
Reply With Quote
  #13  
Old 03-24-2018, 06:37 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Take a look, again, at my original post, which tells you how to do this, without macros.

No empty paragraph is needed or desirable. Generally speaking, empty paragraphs are a bad thing. 2.2 Why you should press Enter only once to end a paragraph

Instead, you can use larger spacing-after paragraph formatting as part of the style for that last answer.
yes; but:
1- how can I make last choice to have the 'third style', going through +10,000 questions?
2- how to deal the numbering; not all questions have [A-E] choices; so 'third style' should continue numbering from previous choices. how?!

Thanks
Reply With Quote
  #14  
Old 03-24-2018, 06:45 AM
Charles Kenyon Charles Kenyon is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,472
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by sarah2020 View Post
yes; but:
1- how can I make last choice to have the 'third style', going through +10,000 questions?
Assuming you currently have an empty paragraph between questions and nowhere else, you can use a replacement. If this assumption is correct, write back.

Quote:
2- how to deal the numbering; not all questions have [A-E] choices; so 'third style' should continue numbering from previous choices. how?!

Thanks
See the macro-free document "Question Styles" on my downloads page. The third style is for the last question, regardless of what the letter is. The letter is automatic.
QuestionStylesDownload[1].gif

Last edited by Charles Kenyon; 03-25-2018 at 07:00 AM.
Reply With Quote
  #15  
Old 03-24-2018, 07:09 AM
sarah2020 sarah2020 is offline Paging [keep lines together; keep with next] Windows 10 Paging [keep lines together; keep with next] Office 2016
Novice
Paging [keep lines together; keep with next]
 
Join Date: Mar 2018
Posts: 15
sarah2020 is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Assuming you currently have an empty paragraph between questions and nowhere else, you can use a replacement. If this assumption is correct, write back.

See the macro-free document "Question Styles" on my downloads page. The third style is for the last question, regardless of what the letter is. The letter is automatic.
Attachment 11643
1] yes
2] tested it but didn't work for me:


EDIT: and it didn't change last choice to its style automatically; I had to do it manually
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to add space between lines of bulleted text and a new header but both lines are moving??? Martin_d35 Word 2 02-10-2017 07:13 AM
Paging [keep lines together; keep with next] First Lines dlapham9 Word 1 10-26-2016 07:23 PM
Deleting grid lines but keeping the axis lines CoffeeNut Excel 0 04-01-2013 01:50 PM
Paging [keep lines together; keep with next] Can't get rid of lines. gfswolf Word 6 01-02-2012 02:33 PM
Paging [keep lines together; keep with next] Getting blank lines instead of supressed lines. Welshie82 Mail Merge 2 11-14-2011 01:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:44 PM.


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