Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2011, 01:07 PM
7ajar 7ajar is offline seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2010 32bit
Novice
seach an Excel list elements in word document
 
Join Date: Feb 2011
Posts: 4
7ajar is on a distinguished road
Question seach an Excel list elements in word document

Hi everybody,



I am looking to build a macro or prog. to search and highlight multiple words in a document. (my list to search is in an excel doc but I can copy it in a word doc)
example: find "Alex" and "car" and "15822" etc. in one hundred pages text.

Thank you in advance
Reply With Quote
  #2  
Old 02-01-2011, 01:39 PM
macropod's Avatar
macropod macropod is online now seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2000
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

Hi 7ajar,

You could use a macro like:
Code:
Sub Demo()
Dim arrWords, i As Long
Application.ScreenUpdating = False
arrWords = Array("Alex", "car", "15822")
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .MatchWholeWord = True
  .Replacement.Text = "^&"
  .Replacement.Highlight = True
  For i = 0 To UBound(arrWords)
    .Text = arrWords(i)
    .Execute Replace:=wdReplaceAll
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-08-2011, 12:00 PM
7ajar 7ajar is offline seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2010 32bit
Novice
seach an Excel list elements in word document
 
Join Date: Feb 2011
Posts: 4
7ajar is on a distinguished road
Default

Thank you Macropod,
This is great, it work perfectly.
However, I have a long list witch I will regularly update. It will be excellent if I can pinpoint directly the list and not update it manually in the macro!
Thank you one more time
Reply With Quote
  #4  
Old 02-17-2011, 12:02 PM
7ajar 7ajar is offline seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2010 32bit
Novice
seach an Excel list elements in word document
 
Join Date: Feb 2011
Posts: 4
7ajar is on a distinguished road
Question dynamise the macro

To be make the macro dynamic, I would like to replace :

ArrWords= array ("Alex", "car", 15822")

by the the elements of A2:A1000 cells in sheet3 of my excel document:
C:\Users\ajar\Desktop\list.xls

Thank you in advance
Reply With Quote
  #5  
Old 02-26-2011, 12:38 AM
macropod's Avatar
macropod macropod is online now seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2000
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

Hi 7ajar,

Any particular reason for maintaining the list in Excel, rather than in another Word document (or even a plain text file)?

Whilst retrieving the data from Excel isn't particularly difficult, it adds overheads that can be avoided in the data are in another Word document (or a plain text file).

For an example of reading in a list from another document, see my code at: http://www.vbaexpress.com/forum/showthread.php?t=34992
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 02-26-2011 at 12:49 AM. Reason: Added link to code for reading list from another document.
Reply With Quote
  #6  
Old 03-16-2011, 12:38 PM
7ajar 7ajar is offline seach an Excel list elements in word document Windows 7 32bit seach an Excel list elements in word document Office 2010 32bit
Novice
seach an Excel list elements in word document
 
Join Date: Feb 2011
Posts: 4
7ajar is on a distinguished road
Default

Thank you very much Macropod!
It works perfectly
Thank you again
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedding Excel Object in Word Document Failing brandonf Word 0 10-04-2010 11:45 AM
MS Word to pdf - elements moved SFC Word 1 05-25-2010 11:27 AM
C# API to identify the uncommitted changes in Excel and Word document? althafuddeen Excel 0 04-06-2010 07:40 AM
Exporting word document to Excel scaifea Word 1 01-09-2010 10:57 AM
Connecting word and excel document jmarin Word 0 11-28-2008 02:55 AM

Other Forums: Access Forums

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