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)
Related
I have a simple excel form with an ActiveX control (ListBox)
When I share this over email, the recipient does the following steps:
1. Open the excel
2. Enable Content for the macro
Now - the ListBox grows in size.
I'm unable to dynamically resize or figure out the exact event for "Enable Content".
Is there anyway I can retain the dimensions of the ListBox?
Your problem has nothing to do with sharing the document via email. It has everything to do with window scaling. To prove this to yourself try connecting to a projector with the the excel document open. Use some Active X controls and they will shrink or Expand. I've had this problem and found the only way to avoid it in a reasonable manor is to implant a form inside the excel document that holds all the needed controls or ensure the end user is not scaling their display in any manor.
So I feel a little foolish asking this question. I have spent plenty of time searching and only found a crude work-around. I have given this due diligence before posting.
For controls placed within a worksheet I cannot pull up the properties or even view the name to reference in code. The work-around I came across is if you right-click on the control (listbox in this case) and choose assign macro. It will suggest a macro name with the control name (e.g. ListBox13_change). In the code I refer to this listbox as Sheet2.ListBox13, but getting an error message for missing object.
With ActiveX controls or controls within a userform I can view the properties. I don't know why I am having trouble with this case.
Any guidance is much appreciated.
You can get the real name of the form control from the Immediate Window in the VBE by executing this line:
?Sheet2.Shapes(1).Name
Form controls are actually shapes in the object model.
The above assumes you have no other shapes on the worksheet.
Of course you can also see the name (and edit it) from the Name Box if the control is selected.
Once you have the name you can use it in code like so:
MsgBox Sheet2.Shapes("List Box 1").Top
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.
I'm looking for an event that's raised when a user selects text in the preview pane of an email. E.g. you're viewing an email in the preview pane and select some text. I didn't see anything in the object reference to this effect, but the namespace is so large, it seems like there's always some object somewhere that does exactly what I need, which I'm not aware of.
Overall, what I'd like to do is see if the selected text matches a pattern and if so, insert a sub-menu in the right click menu (the one that says Copy, Who Is, Synonyms, Translate..). Help with this would be appreciated too. I believe the CommandBar is "text", but I'm unsure how to go about accessing this via name.
The Outlook object model doesn't provide anything for that.
We have following requirement to be done via excel and VBA programming. Please check and let me know if it feasible to do so and if not what way would be best to do it.
There would be excel spreadsheet say excel 2007/2010 with 2 tabs.
1st tab contains normal excel data
In 2nd tab user can enter a particular value and then click on a button in same tab. Is it possibly to have a button in excel tab and can it raise events like windows/web applications?
Now if button can be kept in excel and it can raise button click event then on such an event we need to create xml files. Is it possible to create xml files adhering to schema using excel &/or VBA programming
You need to activate the developer tab (from backstage go to Options and check the visibility of this tab) to get access to normal windows controls, like buttons and drop-down lists etc. You can easily place those in Excel sheets and write event handlers: the controls support the full range of events, including OnClick, OnMouseEnter etc...
You can write custom text files directly from VBA, but you can't validate those. The usual way to do so is just to concatenate small XML blocks into a bigger file, so XML output is more like a normal text output. But it works fine and as long as you do not need to perform something really complicated it is also ok.
EDIT: You can easily add references to custom COM objects (.dll or .ocx) and use them directly in your VBA code. One very helpful suggestion (see the comment below) is to use the MS XML library.
To add a reference just open the code editor (Alt + F11) and then go to Options -> References. Most of the references you need will be already in the list and you just have to check them, but you can also add your own custom libraries by clicking on Browse.