|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
I have a word document with more than 75 multiple choice questions follow by their corresponding answers. What I'm looking for is for a macro that will automatically insert the correct answer choice to the question after letter D based on the following parameters:
Answer (A) is correct. Answer (B) is incorrect. Answer (C) is incorrect. Answer (D) is incorrect. Either letter could be the right choice. See the example below: 1. Identify the item below that is not considered practice before the IRS. A. Corresponding with the Internal Revenue Service on behalf of a client. B. Preparing a tax return for an individual. C. Representing a client at an audit. D. Calling the IRS to discuss a letter received by a client. Answer: B----this is where I need to insert the right answer based on the macro. Answer (A) is incorrect. Corresponding with the Service.. Answer (B) is correct. Circular states that practice before the Service. Answer (C) is incorrect. Client’s rights, privileges, or liabilities under laws. Answer (D) is incorrect. Corresponding and communicating with IS. Please let me know if more info is needed. Thanks! |
#2
|
|||
|
|||
Are those list items done as Word lists? Or are they just plain text with "A. ", "B. ", etc. hard-coded?
|
#3
|
|||
|
|||
Macro Needed
Yes, they are done as Word lists but need to save them in plain text so I can import them to a Multiple Choice program that requires the file to be in plain text. The format is the following:
1. Question A. Choice A B. Choice B C. Choice C D. Choice D Answer: D (this is the portion that I need to type manually in Word and would like to automated) Answer (A) is incorrect. Corresponding with the Service.. Answer (B) is correct. Circular states that practice before the Service. Answer (C) is incorrect. Client’s rights, privileges, or liabilities under laws. Answer (D) is incorrect. Corresponding and communicating with IS To summarize, I got all the Multiple Choice Questions in a Word Document but need to enter the Answer choice manually. I don't think they are hard-coded. If you still need more clarification, just let me know. |
#4
|
|||
|
|||
'Quick and dirty but it should do the job. You can build on it from here.
Code:
Sub ShowCorrectAnswer() ' ' ShowCorrectAnswer Macro ' With Selection.Find .Format = False .MatchCase = True .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.HomeKey Unit:=wdStory Do Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = ") is correct." .Replacement.Text = "} is correct." .Forward = True .Wrap = wdFindStop End With If Not Selection.Find.Execute(Replace:=wdReplaceOne) Then Goto Finish Selection.Collapse direction:=wdCollapseStart Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Copy Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "Answer (A)" .Replacement.Text = "" .Forward = False .Wrap = wdFindAsk End With Selection.Find.Execute Selection.Collapse direction:=wdCollapseStart Selection.TypeText Text:="Answer: " Selection.PasteAndFormat (wdFormatOriginalFormatting) Selection.TypeParagraph Loop Finish: Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "} is correct." .Replacement.Text = ") is correct." .Forward = True .Wrap = wdFindStop End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Last edited by macropod; 03-27-2014 at 04:45 PM. Reason: Added code tags & formatting |
#5
|
|||
|
|||
Macro Needed
Hi Larry,
Thank you for the code. Working almost perfectly. I ran the macro for 75 multiple choice questions and is working great but as you said is "quick and dirty". See if the following can be fixed. In my sample, question 17 shows the correct answer (which is C) but it is ADDING the answer for question 18 right after the answer for question 17. It does the same thing whenever it finds answer A in a question. Therefore, every time there is answer A -is moving the answer to the previous question. 17. On December 31, 2010, xxxxxxxxxxxx? A. January 1, 2014 B. January 1, 2015 C. January 1, 2016 D. December 31, 2015 Answer: C Answer: A |
#6
|
|||
|
|||
Silly me!
You'll need to change the second find statement:
Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "Answer (A)" .Replacement.Text = "" .Forward = False .Wrap = wdFindAsk End With Insert a Selection.MoveDown before that block, and change the .Text value as shown: Selection.MoveDown Unit:=wdLine, Count:=1 Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "Answer (A" .Replacement.Text = "" .Forward = False .Wrap = wdFindAsk End With Last edited by Larry Sulky; 03-28-2014 at 07:17 AM. Reason: accidentally included extra code lines in snippet |
#7
|
|||
|
|||
Thank you note!
Hi Larry,
Will test it when I get home but hey, again, thank you for your help. You don't know what this mean to me. You really save me a lot of time and effort when it comes to edit more than 90 files. Keep the good work. You are good at what you are doing!!! Cheers!!! |
#8
|
|||
|
|||
Thank you note!
Here is an update. The macro works beautifully. Job well done...
Thank you for your support!!! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
multiple choice question | ENEMALI | Word VBA | 1 | 09-29-2013 09:05 PM |
SmartArt Tools-Format tab-Shapes Question | jlohrey | PowerPoint | 0 | 02-07-2012 06:21 AM |
Word DOC(X) help - Export to specific format question. | archerman | Word | 3 | 12-28-2010 11:46 PM |
Macro question | PaulY | Word VBA | 1 | 12-22-2010 11:21 PM |
Categories question & replying with attachment question | glitzymama | Outlook | 0 | 03-15-2006 09:32 AM |