![]() |
#1
|
|||
|
|||
![]()
Hi all,
I have a document with over 75 multiple choice questions but for this example I'm only including three (3) of them. So the questions have the following format (the document lists all the questions firsts and then lists all the answer choices with their explanations) Question #1 (ACCA.101069REG-SIM) Mr. Travel is a U.S. citizen who has been a resident of Germany for five years. A. $0 B. $1 C. $2 D. $3 Question #2 (ACCA.101070REG-SIM) Mr. Travel is a U.S. citizen who has been a resident of Spain for five years. A. $0 B. $1 C. $2 D. $3 Question #3 (ACCA.101071REG-SIM) Mr. Travel is a U.S. citizen who has been a resident of Portugal for five years. A. $0 B. $1 C. $2 D. $3 "========================"So all the questions ends here(this info here is not part of the document, just want to emphasize the info. So after all the questions are listed, all the answers to the questions are listed as follows: Question #1 (ACCA.101069REG-SIM) A. Incorrect B. (Correct!) C. Incorrect D. Incorrect Question #2 (ACCA.101070REG-SIM) A. Incorrect B. Incorrect C. (Correct!) D. Incorrect Question #3 (ACCA.101071REG-SIM) A. Incorrect B. Incorrect C. Incorrect D. (Correct!) So, what I would like to have is a macro that will combine or group the questions and answers together, and will insert the answer choice after letter D with the following format: ANSWER: A Therefore, after applying the macro this is how the information should looks like: Question #1 (ACCA.101069REG-SIM) Mr. Travel is a U.S. citizen who has been a resident of Germany for five years. A. $0 B. $1 C. $2 D. $3 ANSWER: B Question #1 (ACCA.101069REG-SIM) A. Incorrect B. (Correct!) C. Incorrect D. Incorrect Ok, this is all for now. Questions, let me know. I hope my request is not confusing. Thanks all, Cheers, rsrasc |
#2
|
||||
|
||||
![]()
Do you have a file containing just the ACCA.101069REG-SIM, ACCA.101070REG-SIM, ACCA.101071REG-SIM, etc. references and their reference text? If so, and if you can organise that into a tab-delimited layout like:
ACCA.101069REG-SIM → Mr. Travel is a U.S. citizen who has been a resident of Germany for five years.¶ ACCA.101070REG-SIM → Mr. Travel is a U.S. citizen who has been a resident of Spain for five years.¶ ACCA.101072REG-SIM → Mr. Travel is a U.S. citizen who has been a resident of Portugal for five years.¶ in a document with just a tab separating the reference from the question, and a paragraph break between entries, the following macro could do it for you: Code:
Sub BulkFindReplace() Application.ScreenUpdating = False Dim FRDoc As Document, FRList, j As Long, StrFnd As String, StrRep As String 'Load the strings from the reference doc into a text string to be used as an array. Set FRDoc = Documents.Open("Drive:\FilePath\FindReplaceList.doc") FRList = FRDoc.Range.Text FRDoc.Close False Set FRDoc = Nothing With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .MatchWholeWord = True .MatchCase = True 'Process each word from the Check List. Tab-delimited strings are assumed, formatted as: 'Find text <Tab> Replace text For j = 0 To UBound(Split(FRList, vbCr)) - 1 StrFnd = Split(Split(FRList, vbCr)(j), vbTab)(0) StrRep = Split(Split(FRList, vbCr)(j), vbTab)(1) .Text = StrFnd .Replacement.Text = StrFnd & vbCr & StrRep .Execute Replace:=wdReplaceAll Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
rsrasc | Word VBA | 4 | 03-28-2014 01:31 PM |
![]() |
Sammie0Sue | PowerPoint | 1 | 12-06-2013 05:51 AM |
![]() |
suerose | Word | 2 | 07-04-2011 07:59 PM |
Creating a MACRO | Nikb3522 | Word VBA | 0 | 10-21-2010 05:55 PM |
creating macro | steveb | Word VBA | 0 | 08-14-2010 01:29 AM |