hi,
is have a visio diagram with series of text boxes around the visio, is there a way to make a particular text box change color / pop up when clicked? so that it stands out when clicked?
thanks,
Surinder
Single click: no; double click yes. In the event section of the shapesheet, in the double click cell, you can set formula to change font color. You could set it up to toggle between normal and highlight colors. There are a variety of ways to implement this.
What do you mean by "pop up"?
Wapperdude
Here's one approach. Uses double click event. Toggles fill color.
Open shapesheet and add User Defined section. Change row name to: User.HiLite. Enter FALSE into value cell.
In the Events, double-click cell, enter the following formula: =IF(User.HiLite,SETF(GetRef(FillForegnd),RGB(255,255,255)),SETF(GetRef(FillForegnd),RGB(255,255,0)))+SETF(GetRef(User.HiLite),NOT(User.HiLite)). Note: assumes white is normal fill color. If not, edit the RGB(255,255,255) for desired color. The hilite color is yellow. That, too, can be edited.
Now, double click will toggle between Yellow and White.
Wapperdude
Surin:
Single click: Yes. Press alt-F11 and copy the macro below into Visio Objects/ThisDocument. Close and re-open your document, and be sure to enable macros when asked.
The macro makes all shapes on the page yellow fill with red outline when selected, and white fill with black outline when not. Change the colors any way you like.
Good luck,
- Ken
Option Explicit
Public WithEvents WindowEvent As Visio.Window
Public Sub EnableEvents()
Set WindowEvent = Nothing
Set WindowEvent = ActiveWindow
End Sub
Private Sub Document_BeforeDocumentClose(ByVal doc As IVDocument)
Set WindowEvent = Nothing
End Sub
Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
EnableEvents
End Sub
Sub ColorSelectedShapes()
Dim I As Integer
With ActivePage
If .Shapes.Count > 0 Then
For I = 1 To .Shapes.Count
.Shapes(I).Cells("FillForegnd").Formula = "=RGB(255,255,255)" ' Make fill white
.Shapes(I).Cells("LineColor").Formula = "=RGB(0,0,0)" ' Make outline black
Next I
End If
End With
With ActiveWindow
If .Selection.Count > 0 Then
For I = 1 To .Selection.Count
.Selection(I).Cells("FillForegnd").Formula = "=RGB(255,255,0)" ' Make fill yellow
.Selection(I).Cells("LineColor").Formula = "=RGB(255,0,0)" ' Make outline red
Next I
End If
End With
End Sub
Private Sub WindowEvent_SelectionChanged(ByVal Window As IVWindow)
ColorSelectedShapes
End Sub
Private Sub WindowEvent_WindowTurnedToPage(ByVal Window As IVWindow)
ColorSelectedShapes
End Sub
@Ken: using a macro has the appeal of not needing to edit the shapes. However, the single click means it'll fire every time a shape is selected...which is why I said "no". But, it is really convenient. I'd think a slight tweak to macro would make it more enduring. Namely, change the triggering to either a long press or to a double click. The double click might run into conflict if the shape has a double click event. Not sure if Visio has a long press event.
Cheers,
Wapperdude
Wapperdude:
Convenient indeed. Remember that I studiously try to avoid extra clicks and keystrokes, so convenience is the watchword. Besides, it was fun to toss the code together. I never seem to get enough of it. And I guess I took your "single click: no" as a challenge. ;- )
Not sure of your concern, but I'm generally not too concerned with a macro firing whenever a shape is selected. For example, my double click back button (http://visguy.com/vgforum/index.php?topic=7163.msg30175) fires on every Mouse Down and Mouse Up. (That code still has some issues, by the way, that I have not yet had time to address; but I digress.) As for a long press event, I'm not aware of one in Visio. Shouldn't be a big deal to implement, though; just time the difference between Mouse Down and Mouse up—but then they'd be firing all the time. Wouldn't want you to get concerned... ;- )
All the best for the holidays to you and all the Forum Folk.
- Ken
Hey Ken,
It's a personal petty thing. You like keeping things simple, I dislike repetitive, for me it's annoying, like nagging. You know..."You selected to opt out of email, please confirm...Did you really mean to opt out?...Opt out is non-revocable action, are you sure?" Aaaargh! Just do it already! So, if the macro fires, during the normal course of doing things, it would invoke that response from me. 😵😱
But, the original poster may be happy with it.
Glad I could issue a challenge. ;)
Merry Christmas, happy holidays. :)
Wapperdude