Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 22,523
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 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
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
 



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 08:07 AM.


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