Search code examples
vbavisio

Programmatic access to Visio shape tooltip


To avoid an XY problem, here's what I'm trying to accomplish: when a shape is selected, I want detail text about that shape to appear on the screen.

I first tried using Shape Data, but it supports only single-line name=value pairs. My detail information is an arbitrary, multiline text blob.

My next thought was to used the shape's ScreenTip (aka tooltip) to hold the text data, then write some VBA code to handle the _SelectionChanged event. When a shape is selected I want to copy it's ScreenTip text into the text of another object (my details panel).

I got the _SelectionChange event-handling working, but poking around the Selection object in the debugger I can't find any property of the selected object that exposes the ScreenTip information.

Is Visio's programming API too anemic to support his kind of thing? Is there another way I might be able to do this? Is there another tool that might be better for this (preferably free)?


Solution

  • Visio's API is capable of doing this, handily.

    It seems you're not aware of Visio's shapesheet, which is where the screen tip text is stored, along with pretty much anything you'd want to know about a shape.

    To access the screen tip text you simply read the Comment cell from the selected shape's shapesheet:

    Application.Selection(1).CellsU("Comment").ResultStr(visNone)
    

    This code will return the comment text.

    You're on the right track using the SelectionChange event, though of course you're checking that the selection count = 1, or at least >0.