vba updateable shape controls in master shape - vba

I am having a bear of a time finding an answer to what seems like a simple question. I am using Visio 2010. I need to have something like text box that I can update through VBA. I have to code to do it
shape.CellsU("Prop.Memory").Formula = """256 MB"""
for example (shape is a variable in this case). The problem is that I can't find out how to tie a control, like a text box or label, to a user defined property like "Prop.memory" in this case. I thought it might be a data graphic but adding a data graphic is disabled for me.
Michael.

I think that I have a solution. It is an odd one but it might work. The problem is that you cannot apply Data graphics when you have the master open in edit mode. what you can do is drop the master on the sheet based on the recordset. now you can add data graphics because it has a record source (I am guessing). I made the changes I need to that layout that I needed. I then dragged that shape to the stencil to become a new master. it will maintain the data links. it seems like an odd way to go about it but it does work. I might be good for now.
update: this didn't work for what I needed. I did find the way, though, on this site: Creating custom Visio shapes
Once you create the shape with the right fields, you have to use something like the following code to update it via VBA:
shp.cells("prop.Memory").Formula= chr(34) & "256 MB" & chr(34)
where shp is a visio shape
I just wanted to be the solution that I found is out there.
Cheers, Michael.

Related

Set textbox line appearance to a gradient using Word VBA? (2016)

Context: I'm setting up a macro to format textboxes independently of current template or textbox defaults, in Word 2016. To be clear, No, I cannot depend on the "Set Textbox Defaults" option.
The design I have to replicate puts a linear gradient on the outer textbox's border, going from a dark color at the top to white at the bottom. Pretty simple, right? Except I can't figure out how to tell VBA to accomplish this.
Normally I record a macro to see which properties to change, but the Macro recorder isn't saving any edits to the Shape format.
Manually I got as far as outputting the .Pattern used on the textbox.Line object via Debug.Print: Word returns -2 (msoPatternMixed) which is "Not supported" according to Microsoft's reference docs.
I don't know how to get any further.
Could anyone share some example code that'd let me set the line gradient through VBA?
Or: tell me how to force the Macro Recorder to save the changes I'm making in the Format Shape dialog? It's incredibly annoying that it refuses to show me anything.
Thanks!

Does anyone understand the SlideMaster property of the Powerpoint Presentation object?

I refer specifically to the 2016 version, but this should also apply to 2013 and 2010.
----- TLDR Summary
Is it possible to use VBA to add a new Slide Master using a method
that I haven't found?
Is it possible to use VBA to access or manipulate the Layouts of
Slide Masters other than the first one in a Presentation object?
I suspect that the answer to both is "No" and that MS has merely
screwed up the exposure of the underlying objects, but others may
know more about programming PPT than me.
------ The Whole Question
Microsoft has deemed PowerPoint unworthy of a macro recorder for lo these many versions (I think it was dropped in either 2003 or 2007 from memory), so no help can be obtained from there.
The linked MSDN "help" item is woeful. It states that the property returns a Master object, though that isn't relevant for the moment.
An Office support page describes a slide master here. A Slide Master seems to be where the presentation's Slide Layouts live, presumably in the SlideMaster's CustomLayouts property, though it's interesting to note that only the first 9 of those CustomLayouts correspond to what you see in the GUI. (I count 11 CustomLayout objects in the SlideMaster in a new, blank presentation.) The numbers change if you add new layouts though the two vertical text layouts never seem to appear in the GUI list. This too is not the problem.
The problem is that you can in fact have more than one Slide Master per presentation by going to the View menu, Slide Master, and then selecting Insert Slide Master. Having multiple Slide Masters is discussed on the Office Support site here.
Frankly I regard this functionality as slightly broken because if you do that, then apply a Theme to the new Slide Master, you end up with a third Slide Master; the original under "Office Theme", a second under "Custom Design", and a third under the name of the Theme that you applied. This too is not in itself a problem. (Though it's worth noting that a Presentation does not have an AddSlideMaster method, which means that it does not seem to be possible to do this by VBA. Not that you necessarily want to, but if you did, you can't. There is only an .AddTitleMaster method which seems to be useless since all presentations have a TitleMaster as far as I can see and if a presentation has one then that method will error out according to the documentation.)
The problem is that the Presentation object does not have a collection of Slide Masters. It has only that one property, SlideMaster, which returns a single Slide Master / Master object.
Accordingly I can't see any way that you can programmatically add a new Slide Master. And even if you used one that is added through the GUI you can't seem to access any Slide Master except for the first one. And therefore you don't seem to be able to access, manipulate or assign any Layout from any Slide Master other than the first one to an individual slide.
Am I correct in this assumption, or am I missing something?
I shall offer thanks in advance even though that is often deleted from questions. Not that this one is likely to attract much attention; I suspect that there may be another Tumbleweed badge in my future.
Perhaps this page will be helpful in understanding it better - http://skp.mvps.org/2007/ppt003.htm

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

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.

What is this VB.Net script and how do I add coloring to its cells?

I am given a task where I have this VB.Net script that produces and populates a grid and I must add coloring to each grid cell.
Problem is that this freeware given to me is 5 years old and I don't know what the name of this freeware is; I was only given the source files.
I am not entirely sure of how this script works because I am a C# person so I was hoping someone on here might know the freeware's name or what its functionality is so they can explain it to me.
There seem to be 4 files in the freeware folder and below is their screenshot:
I am currently sitting and trying to understand the code for PrintDGV.vb which might or might not be useful in understanding the freeware.
I am not familiar with any of these files but here is the code for PrintDGV.vb
Looks fairly straight forward.
You pass your DataGridView control to it and it looks like it will handle the printing for you:
Call PrintDGV.Print_DataGridView(YourDataGridViewControl)
It's a shared function so you don't need to instantiate it. For coloring your cells, just set the backcolor of your grid cells and it looks like it will use that in the printing process.
To change a color of an individual cell in the DataGridView control:
YourDataGridViewControl.CurrentCell.Style.BackColor = Color.Red