Add some (Master) Shapes to another (Master) Shape in Microsoft Visio 2013 x64 when add a (Master) Shape to the Page - shapes

I want to create a new Master Shape in the Microsoft Visio 2013 x64 like the Class Master Shape in the UML Class Stencil.
When add the Class Master Shape to a page, it appends two Member and one Separator Master Shapes in itself automatically. Furthermore, can add more Member and Separator Master Shapes in it.
I was thinking that it adds other Master Shapes in itself by some written VBA codes; however, when I checked the file of the UML Class (Metric) Stencil in the following full path, I got that it uses no VBA codes, not at all.
D:\Program Files\Microsoft Office\Office15\Visio Content\1033\USTRME_M.VSSX
The file extension is "Visio Stencil (.vssx)" instead of "Visio Macro-Enabled Stencil (.vssm)"; so, it can't have VBA codes.
I know that I can do something by adding some new Rows in the Actions Section of the ShapeSheet; however, it doesn't exist any action Rows to add fresh Member and Separator Master Shapes for Class Shape.
Figure 1 - Separator Shape with two additional options in the Context Menu and without any related rows in the ShapeSheet
Figure 2 - Display a Bar to insert Separator Shape
Figure 3 - Member Shape with two additional options in the Context Menu and without any related rows in the ShapeSheet
Figure 4 - Display a Bar to insert Member Shape
When I do RMB click on a Class Shape that is placed in the page, it has two new options in the Context Menu:
Show Template Parameter
Show Stereotype
And I see related Actions' Section Rows for them.
Figure 5 - Class Shape with two additional options in the Context Menu and related rows in the ShapeSheet
When I do RMB click on the Member and Separator Shapes in added Class Shape, can see "Insert "Member/Separator" before/after"; however, when I add Member and Separator Master Shapes on the page directly (not in the Class Shape), when I do RMB click on them, can't see extra options in the Context Menu.
Figure 6 - Separator Shape with no additional options in the Context Menu
Figure 7 - Member Shape with no additional options in the Context Menu
I checked their ShapeSheet and can't find any related rows for above-mentioned actions.
Now, my question is that how can I create a new Master Shape with the ability to accept some other Master Shapes without any VBA codes like Class Shape in the UML Class Stencil that is created by Microsoft?

This feature is called "List" (structured diagram) in Visio (was introduced in Visio 2010). To allow this sort of functionality (allow some shape to "accept" others similarly to "class" shape), you need to declare the shape to be a "list", by setting the user property User.msvStructureType="List" in it's shape sheet. To declare type of items it should accept, you also need to set the cell User.msvSDListItemMaster = USE("Your item's master name"). Means, you can just draw a plain rectangle (for example) and then convert it into a "List" by adding these two user properties. There are more options available for lists/container (such as margins, behavior, etc).
The MSDN article describing this functionality in details: http://blogs.msdn.com/b/visio/archive/2010/01/12/custom-containers-lists-and-callouts-in-visio-2010.aspx

Related

How would i loop through the graphicItems each item in Visio using vba?

I have a graphics as per the below snap, where i want to make Bold to the 1st item and last item should be italic. So to achieve this i think i have to loop though the each item of the certain graphics in Visio.
So i have tried the the below VBA code, but it only displays the graphics item ID and name. 
For intCounter = 1 To ActiveDocument.Masters.Count
If ActiveDocument.Masters(intCounter).Type = visTypeDataGraphic Then
Debug.Print ActiveDocument.Masters(intCounter).Name, ActiveDocument.Masters(intCounter).ID
End If
Next
So I need the detail process to loop through the graphics item for each element so that my findings can be handled ?
I have several data graphics entities in a page and I want data graphic item should be changed all such entities at once. I don't find any option in "Edit Data Graphic" to change its item wise properties like 'Bold', 'Italic' etc.
When you link External data with your document Visio engine automatically add few hidden build-in master shapes to Document stencil.
You can find these changes via Drawing Explorer window.
Each master shape contain some sub-shapes into.
You must iterate these sub-shapes!!!

PowerPoint VBA add shape event/ add shape with tag value

i'am currently trying to add a small function to PowerPoint using VBA, my goal is to create a gadget that works kind of like Photoshop graphics layer.
My plan is to add a layer name Tag on each shape that is drawn by user, so later I can parse through every item by loop and preform lock/unlock, show/hide shapes based on it's tag value, such as:
Sub add_shape_with_layer_tag()
Set islide = ActivePresentation.Slides(1)
Set ishape = islide.Shapes.AddShape(msoShapeRectangle, 5, 5, 80, 60)
ishape.Tags.Add "Layer", "1"
End Sub
Sub show_hide_layer_one_shapes()
Dim active_slide As Slide
Set active_slide = ActiveWindow.View.Slide
For Each ishape In active_slide.Shapes
If ishape.Tags("Layer") = "1" Then
ishape.Visible = Not (ishape.Visible)
End If
Next ishape
End Sub
However, I couldn't found a way to achieve this, so I would like to ask whether there's a method that provides following functions?
override add shape function so I can sneak tag value in to shape every time user drawn a shape
catch add shape event (if this thing did exist) so i can add tag to the last added item
a way to set a default tag value to shape, just like setting default shape color/line width
or is there any better options that is also viable?
thanks.
20200728
To John, thanks for the advice, I did found some interesting event that might be helpful for some of my other projects, however I couldn't found events that able to trigger after custom function while shape is added.
To Steve, my plan is to add a modeless userform with list UI that manage layers, the shape tag and shape fill texture/color will be determined based on what list item that currently selected.
As to saving settings, I'll use VBComponents.CodeModule to dump existing settings in userforms to a VBA module and store as text, so in theory I should able to make this function self contained in one file.
Not totally an answer, sorry SO, but comments don't allow enough scope for this. So ...
To Steve, my plan is to add a modeless userform with list UI that manage layers, the shape tag and shape fill texture/color will be determined based on what list item that currently selected.
Ah, so you're creating your own "pseudo-layers". That wasn't clear. Thanks for the add'l info. As it happens, I have a selection manager add-in that works very similarly to what you're proposing.
To John, thanks for the advice, I did found some interesting event that might be helpful for some of my other projects, however I couldn't found events that able to trigger after custom function while shape is added.
The SelectionChange event should get you there. When it fires, you'll need to check first to see if the current selection is a shape or something else. If a shape, check to see if its .Index = current slide's .Shapes.Count and also to see if you've already tagged it. If no tag AND if it's the correct index, it'll be a newly added shape. If you're tagging ALL shapes, you may only need to check to see if the .Tag(name) is blank.
As to saving settings, I'll use VBComponents.CodeModule to dump existing settings in userforms to a VBA module and store as text, so in theory I should able to make this function self contained in one file.
Why not save any needed slide or presentation level info as further slide- or presentation-level tags? PPT can absorb quite a lot of info as tags w/o getting cranky.

Finding id of shape dragged onto screen in Visio using VBA macro

I currently have a program in Visio that when a specific shape in my custom stencil is dragged onto the screen, a user form comes up and asks the user a question with a combo box used for the user to select an answer.
Based on the answer selected, the shape data should change for that object.
The problem that I am facing is that I am not sure how to target the ID of the shape automatically to then change its shape data. Since multiple of these shapes may be placed, I can not manually write a new piece of code for every ID.
Image: Shapesheet of the shape running the macro on drop. "Form" is the user form.
Image: Userform macro
I would be very grateful if someone could help me with this problem.
Thank you
I wonder if the CALLTHIS ShapeSheet function might be more useful here as it passes a reference to the calling shape. So, for example, in the EventDrop cell add this formula:
CALLTHIS("ThisDocument.OnMyShapeDrop","Drawing001")
and then add this backing code:
Public Sub OnMyShapeDrop(shp As Visio.Shape)
MsgBox "Shape dropped - ID = " & shp.ID, vbOKOnly, "Shape Dropped"
End Sub
Note, that I've put the code in the ThisDocument class, but it can live in any accessable module. Also note the project name (Drawing001) which will likely be the file name without the extension.

Pentaho - Draw a target line in bar graph using Pentaho Report Designer

I need to draw a target line as shown in the image using Pentaho report designer in a Pentaho Bar Graph.
you have two options.
1) using secondary data-source
2) bean-shell scripting
let me explain 1st option which is simple,
1)once you will double click on chart you will get two options on right side,Primary datasource and secondary datasource.
2)in secondary datasource specify categoty-columns and value-columns the field you want to display.
3)then in bar left side properties go to line options category and give details like line-style= solid, line-series-color=orange(specify colorcode) etc..

Setting shape position to book layout in vba

I want to use a word macro to set the position of the shapes in the document to book layout (see screenshot). But I can't find any reference which member I need to set for this (probably because my word is in german and this is called differently in the macro).
Can anyone tell me how to set the horizontal layout of a shape to book layout in vba?
[update] The following did the trick:
Shape.Left = -999994
Shape.LeftRelative = -999999
Shape.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
In the most recent versions of Word the macro recorder gives no help for graphical objects. The next best thing you can do is to look at the properties available for the object in the Object Browser (F2).
If a graphical object has "text wrap" formatting then it belongs to the Shapes collection, so the list you need to look up is that of the Shape object.
In there you'll find the property RelativeHorizontalPosition, which takes a member of the WdRelativeHorizontalPosition enumeration. Looking at that list there are a number of options, none of which has "book" in it.
So the next step is to insert and format a Shape with the desired positioning. Then in the Immediate Window (Ctrl+G) you can type:
?ActiveDocument.Shapes(1).RelativeHorizontalPosition
Then press Enter. This will print a number that corresponds to the list of Enumeration members.
You can also test the effect of the various members by assigning them in the Immediate Window:
ActiveDocument.Shapes(1).RelativeHorizontalPosition = wdRelativeHorizontalPositionOuterMarginArea
Press Enter.
What you'll see is that there is not an enumeration member for every option in the dialog box. And that various positioning options in the dialog box correspond to a single enumeration member.
For your specific question, wdRelativeHorizontalPositionInnerMarginArea corresponds to the dialog box option you indicate.
ActiveDocument.Shapes(1).RelativeHorizontalPosition = wdRelativeHorizontalPositionInnerMarginArea
Besides the above, you need to use the LeftRelative and Left properties, as well. Take a look at those settings in the Immediate Window after using the dialog box and play with them, putting the image on odd/even pages.If it disappears - it's off visible portion of the page, which you can see in Reading View. In a nutshell, you need the NEGATIVE numbers to lock the image to the margin or page side. Positive numbers position it absolutely.