Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-16
4
Medium Priority
?
239 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

715 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