Programmatic access to Visio shape tooltip - vba

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)?

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.

Related

Best way to implement a dialogue system in Game Maker Studio 2

I am trying to implement a dialogue system for a game that I am making. I have the actual system for handling the text and input all set up. My question is asking about how you actually show the text and have it formatted properly in a certain sprite.
The "best way" is a broad and subjective term, and it may be different for each person, but I can give you some tips regarding the question in your second sentence, to put you in the right direction:
How to actually show the text and have it formatted properly in a certain sprite?
Considering a dialogue box is a User Interface, you should put the code, that draws the dialog box, in the Draw_Gui of the object. Because that will draw stuff in front of the camera, and doesn't need to keep positions of the map in mind. Since Draw_Gui is in an object, you can put the dialogue box in a parent NPC, or let a seperate persistent object handle it (called an object manager)
To format it properly within a sprite, you can use draw_text_ext(x,y,string,sep,w), especially the w parameter will be helpful, as that allows you to let the text start on a new line if it exceeds past that width, and the sep parameter let you deside the space between the lines of text, to ensure the amount or lines in your dialog box will look clean.

VBA script to insert anchor position for autoshapes in Microsoft Word 2007

I'm beyond the limits of my kindergarten-level VBA skills so would like to ask if anyone here can help me write a VBA script to help me work stepwise through my Word document and adjust the anchoring position of all the AutoShapes in the document.
I have a 400-page book in Microsoft Word with at least one and sometimes several marginalia (sidenote) on each page in a thin column to the left of the main body text column. These sidenotes are a concise 'pointer' to a particular point made in the body text and need to appear directly to that point's left.
Each sidenote is in its own AutoShape (within a textbox in that shape). The AutoShapes were placed by the author in an inconsistent way. Mostly they are anchored to a position on the page.
However, I need to repaginate. This will cause the body text to flow differently and I need the sidenotes to flow with it (approximately or exactly)!
So before I repaginate I want to make sure I anchor each AutoShape to the paragraph it belongs to and not to the page it is currently on.
I don't know if that can be done automatically, since I don't know how Word could deduce a purely spatial relationship between an AutoShape and a paragraph.
So I'm guessing I have to make do with a "semi-automatic" process. Something like this:
Press a button to start VBA script
Select next AutoShape
Prompt for user to enter cursor in body text where anchor is to be placed
Resume macro
Place anchor for that AutoShape in that position
Change vertical position paramater of AutoShape to "relative to paragraph"
and "0 mm"
(Alternative, not 0 mm but another value deduced to more
accurately position AutoShape)
Change width parameter of AutoShape to
a particular fixed value 37 mm (some of them were a little
inaccurately drawn)
End cycle and go back to beginning to
Select next AutoShape
Hope that is all understandable.
I've tried to record a VBA script to do some of this but have no idea how to build in the user prompt.
Any help much appreciated!
Craig
You may be better off creating a macro that works on one shape at a time, or anchor all the shapes manually (which you're almost doing anyway) and then write a macro to take care of the various parameters and settings you want.
If you really want to prompt the user while the macro is running you'll need to look into modeless dialogs (not possible on the Mac). See this link: http://www.bettersolutions.com/vba/VXV113/SE846743531.htm
Basically, you'd have to create your own dialog and then show it modelessly so that the user could still place the cursor before hitting OK. If you're new to VBA, this could be difficult to set up.
While searching for solutions to this, I found a post on another forum from someone trying to do something very similar. He was developing a set of tools for editors using Word and until I find the ultimate solution I am using his "Shapes" tool which allows me to change parameters on each AutoShape I select at-a-click instead of opening up and closing a dialogue box each time, plus selecting a different tab each time... His tools can be downloaded at his Editors' Toolkit website.

Shape click opens external data tab

I am trying to get my visio to be able to open a certain external data tab when a certain shape is clicked. I have found how to link the data from a specific row to a shape but not the other way around. Is this even possible?
It looks like this will help you VISIO - highlight specific row in the data file when clicking on the corresponding shape in Visio.
Some of the highlights include: The way to gain access to that window is to loop through each of the ActiveWindow.Windows. When you come across one that has the ID of visWinIDExternalData then you can control the Window.SelectedDataRecordset and Window.SelectedDataRowID properties. The code left by the Microsoft MVP in that forum also includes how to get the DataRecordsetID and DataRowID from the selected shape thus enough data is available to provide the window with the selection that you desire.
Additional resources:
Shape.GetLinkedDataRow Method (Visio)
Shape.GetLinkedDataRecordsetIDs Method (Visio)
Window.SelectedDataRecordset Property (Visio)
Window.SelectedDataRowID Property (Visio)

How to hyperlink Visio Characters object

I'm working on a VBA macro to automatically add hyperlinks within a drawing file, so that when a certain word is mentioned in the text, I can link to another page in the drawing.
According to MSDN and Visio's help, a Hyperlink object can be associated with a cell, characters, row, or section object. However, I can't find any way to actually associate a hyperlink with anything but a shape.
So the question is, how can I hyperlink a single word within a paragraph of text in a single shape in Visio?
I'm only familiar with two ways to trigger a hyperlink navigation within Visio:
Add a Hyperlink to a shape and click on the shape (or select the hyperlink from the shape's context menu).
Add a call to the Hyperlink shapesheet function in a cell formula. Making a change that triggers that cell's recalc would then follow the hyperlink.
The best idea I can think of, and it isn't very good, is:
Make sure your shape is a group - if it isn't, convert it to group.
Change the group's properties to SelectMode=visGrpSelModeMembers1st and DisplayMode=visGrpDisModeBack.
Drop a new shape, sized and centered over the word in question. Make the new shape transparent (partial transparency here could be used for highlighting).
Change the DblClick event's formula to "Hyperlink("yourURLhere")".
Add that shape to the group.
Now, double-clicking on the word should actually involve double-clicking on the new subshape, which will trigger the hyperlink. This is really only viable if your shape is designed to work with this idea - many out-of-the-box shapes will not work well here, as steps 1 and 2 can have ugly side-effects.
I hope someone else knows a more elegant way around this problem.

Setting Lotus Notes section border using VBA

Friends,
I'm using VBA to create Lotus emails populated from an Excel spreadsheet, and I'm stuck on a really silly point.
When I create a new section in the note, business rules require me to give it a border. They've been doing this manually for years and are used to doing this from the Notes UI. They create a new section, then go to its properties and then change it to have a border (please see the border and style part in the properties window in this screenshot).
I can't figure out how to add this border through VBA. Any ideas? I've tried changing the TitleStyle, but that only affects things like fonts and color. I have everything else done, just stuck on the border!
Thanks!
Mike
The NotesRichTextSection class doesn't give you any way to change the border, unfortunately. Rich text items in Lotus Notes aren't supported very well via the API, so often you'll find a mismatch between what you can do on the client vs. what you can do in code.
There might be a workaround if you're up for trying it. First you need to create a simple form in Notes that has a rich text field, let's call it Body, surrounded by a section. Setup the section to appear however you want, with the border set, etc. You'll also need another hidden text field, called Title, and you'll set the section's title to be computed based on that Title field.
Then in your VBA code you're going to create a new NotesDocument based on that form. You'll set the Title field, and you'll add content into the Body rich-text item. Then you'll need to call the ComputeWithForm method followed by the Save method. Finally, you can use the RenderToRTItem method on the document to put the entire document into your original note's rich text field. Make sense?
No guarantees that will work from VBA, but I've done similar things in the past using LotusScript and it did the trick.
You could just set the borders of the cells you are copying using the Borders() property.
Example:
Range("B2:C4").Borders.LineStyle = xlDash
Range("B2:C4").Borders(xlEdgeBottom) = RGB(255,0,0)