Solved

vba that detects if text is in front of a shape and changes its color or highlite

Posted on 2013-01-16
4
238 Views
Last Modified: 2013-01-29
I add lots of picture to my word documents and would like to have vba change the color of any word with a picture behind it to say yellow. Ist that possible?
0
Comment
Question by:Dov_B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 38798271
Hi,

This could help

Sub HighlightWordBeforeImage()
Selection.GoTo wdGoToBookmark, , , "\EndOfDoc"
With Selection.Find
  .Text = "^g"
  .Forward = False
  Do While .Execute     'Returns true if the defined text was found.
    Selection.Move Unit:=wdWord, Count:=-3
    Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Range.HighlightColorIndex = wdYellow
    Selection.Collapse
  Loop
End With
End Sub

Open in new window


See example
HighlightWord.doc

This code only works if the word has one punctuation after it (like period, comma, tab, etc.), if not adapt the count at line 7.

Regards
0
 

Author Comment

by:Dov_B
ID: 38799441
Thanks so much for sharing your expertise. My pictures are floating not inline and they float under the text I chose the wrong words when I saind behind the text. if it helps the word on top of the picture has a bookmark in it.
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 38799971
Hi,

Could you send a sample of the file or a dummy example?

Regards
0
 

Author Comment

by:Dov_B
ID: 38824340
here is a screanshot of a clipart behind or beneath the text Ineed to be able to make a macro that will change the color or highlite of the text so that it is readable against the background clipart
for-kicking-with.png
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question