Highlighting part of shape text

P

Paul Herber

I'm trying to replicate part of the 'Find' functionality, but with
special features.

I've got the shape selected and I've done a doCmd(visCmdDRTextTool) to
get into edit mode.

Now, how do I just select and highlight part of the text, say from
character 3 to character 5 ?

MTIA.
 
M

Markus Breugst

Hi MTIA,

I don't know if you can select a part of a shape text. However, it's
possible to highlight it.

I've written a little macro for you to show how this works. The macro sets
the color of the first two characters to red, the 3rd to 8th to green, and
the 9th to 10th to blue. Hope this helps.

Best regards,
Markus

Public Sub ColorIt()
Dim myChars As Characters
Dim myShape As Shape
Dim index As Integer
Dim rowNumber

For index = 1 To ThisDocument.Pages(1).Shapes.Count
Set myShape = ThisDocument.Pages(1).Shapes(index)
Set myChars = myShape.Characters
myChars.Begin = 0
myChars.End = 2
myChars.CharProps(VisCellIndices.visCharacterColor) = 2
myChars.Begin = 2
myChars.End = 8
myChars.CharProps(VisCellIndices.visCharacterColor) = 3
myChars.Begin = 8
myChars.End = 10
myChars.CharProps(VisCellIndices.visCharacterColor) = 4
Next index
End Sub

Paul Herber said:
I'm trying to replicate part of the 'Find' functionality, but with
special features.

I've got the shape selected and I've done a doCmd(visCmdDRTextTool) to
get into edit mode.

Now, how do I just select and highlight part of the text, say from
character 3 to character 5 ?

MTIA.
http://www.sandrila.co.uk/
 
M

Markus Breugst

Sorry Paul for calling you "Many Thanks in Advance". That's the
abbreviation, right? Well, it's Sunday, and my mind is a bit slow. :)
 
P

Paul Herber

Hi MTIA,

I don't know if you can select a part of a shape text. However, it's
possible to highlight it.

I've written a little macro for you to show how this works. The macro sets
the color of the first two characters to red, the 3rd to 8th to green, and
the 9th to 10th to blue. Hope this helps.

Thanks Markus,
That's similar to what I want but it does mark the document as changed
and I'd need to keep track of the original text formatting so that it
can be restored.
However, I think I may have found a solution by sending cursor control
keys.

P.S. I've been called worse than MTIA !
 
J

John Marshall, MVP

Two things,

1) Visio does have an Undo feature that will roll back the changes and
should mark the document as unsaved (if that was the state before you did
the changes.)

2) The macro record is a quick way of trying to determine how something is
done in Visio. (It also includes examples of using Undo)

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 
P

Paul Herber

Two things,

1) Visio does have an Undo feature that will roll back the changes and
should mark the document as unsaved (if that was the state before you did
the changes.)

I'm fine with handling undo, I use that, but I've just done some tests
in Visio 2000 and 2003, the unsaved status isn't retained.
Any change sems to set the unsaved status.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top