Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2014, 01:01 AM
rsrasc rsrasc is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Competent Performer
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 03-27-2014, 01:06 PM
Larry Sulky Larry Sulky is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default

Are those list items done as Word lists? Or are they just plain text with "A. ", "B. ", etc. hard-coded?
Reply With Quote
  #3  
Old 03-27-2014, 01:26 PM
rsrasc rsrasc is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Competent Performer
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default 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.
Reply With Quote
  #4  
Old 03-27-2014, 01:49 PM
Larry Sulky Larry Sulky is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default

'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
Reply With Quote
  #5  
Old 03-27-2014, 02:20 PM
rsrasc rsrasc is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Competent Performer
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default 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
Reply With Quote
  #6  
Old 03-28-2014, 06:37 AM
Larry Sulky Larry Sulky is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default 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
Reply With Quote
  #7  
Old 03-28-2014, 07:50 AM
rsrasc rsrasc is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Competent Performer
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default 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!!!
Reply With Quote
  #8  
Old 03-28-2014, 12:28 PM
rsrasc rsrasc is offline Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Windows 7 64bit Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Office 2010 64bit
Competent Performer
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Thank you note!

Here is an update. The macro works beautifully. Job well done...

Thank you for your support!!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question 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
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question Word DOC(X) help - Export to specific format question. archerman Word 3 12-28-2010 11:46 PM
Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft