Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2015, 02:00 PM
tingker tingker is offline Help with macro Windows 7 64bit Help with macro Office 2010 64bit
Novice
Help with macro
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default Help with macro

Hello,
I need help creating macro that will strip the document of a series of tags and replace it with new tags. See attached document. The tag that I need to strip out is highlighted in yellow and the new tags are in a separate document.

I have a series of document and I just want to check if there is an easier way than just copying and pasting. Thanks.



Any feedback will be greatly appreciated!

Many thanks in advance!
Attached Files
File Type: docx test_mc_ch01.docx (30.0 KB, 11 views)
File Type: docx YCMY8TU16584755F8172.docx (14.0 KB, 10 views)
Reply With Quote
  #2  
Old 03-04-2015, 02:16 PM
gmaxey gmaxey is offline Help with macro Windows 7 32bit Help with macro Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

tingker, It looks like you want someone to write your macro for you. "I need help ..." implies you have tried and failed.

I'll give you some code to get you started:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim arrNums() As String
Dim lngIndex As Long
arrNums = Split("QHBB19VKSPW0NRLPU792|MRQFVW0WXN400MH9D416|JHURQ0VND7Q45PUBN011|RACAAYRWYBX840BJU005|" _
              & "PYZL7DR3NME4N5LEB490|CFWSPWA9MA96RS75K298|RYRXH35AK3BHFUGZN987|NPQVJ33EUY66QC0TD738|" _
              & "VLDTH09A33AKJ70NJ153|XWXWU30WZACA7CEBQ776|GTST08D3XR52JCCCE566|TVLCRCUPE6ELKC0U4018|" _
              & "TRYXRUWC3K2GA7249398|JKSG4XX7B4609ZB5K909|CYNFF3LERUXF2S9KS589|AZGRNTJC2HLJCJH4K507|" _
              & "JBPUKJ2JDYHN24R23272|VJPGVMP2JXX8J12EZ883|BUFQK2RMQHMQ5A4JF577|NQDTZ9DLLE8STZSN9996|" _
              & "QUZE112HEU5Q8AE5S194|HMXZQ7WTRNY2KSLBF035", "|")
Dim oRng As Word.Range
  lngIndex = 0
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Highlight = True
    While .Execute
      oRng.Text = arrNums(lngIndex)
      oRng.Collapse wdCollapseEnd
      lngIndex = lngIndex + 1
    Wend
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by gmaxey; 03-05-2015 at 08:38 AM.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with macro Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:08 AM.


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