Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-22-2014, 04:21 AM
rsrasc rsrasc is offline Need Help Creating Macro Windows 7 64bit Need Help Creating Macro Office 2010 64bit
Competent Performer
Need Help Creating Macro
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Need Help Creating Macro

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



Reply With Quote
  #2  
Old 10-22-2014, 03:09 PM
macropod's Avatar
macropod macropod is offline Need Help Creating Macro Windows 7 64bit Need Help Creating Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

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 layout like:
ACCA.101069REG-SIM<tab>Mr. Travel is a U.S. citizen who has been a resident of Germany for five years.
ACCA.101070REG-SIM<tab>Mr. Travel is a U.S. citizen who has been a resident of Spain for five years.
ACCA.101072REG-SIM<tab>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
Simply add the macro to the your document's template, change 'Drive:\FilePath\FindReplaceList.doc' to point to your document containing the list, make the document to be updated the active document, then run the macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help Creating Macro Need Help Creating Macro rsrasc Word VBA 4 03-28-2014 01:31 PM
Need Help Creating Macro Creating a macro button in powerpoint Sammie0Sue PowerPoint 1 12-06-2013 05:51 AM
Need Help Creating Macro Creating a generic macro? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:15 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