News:

Happy New Year!

Main Menu

Recent posts

#1
General Visio / Phase position in a cross func...
Last post by Oonizuk - March 20, 2025, 09:26:20 PM
Hello,

I created a cross functional flowchart in Visio. I wanted to link my template to a excel file database to export text and position of the shapes but my flowchart embedded some List/container so I can not do it. (may I miss something to do it??)

To get back text I tried the "report feature" but I noticed that I can not get back the phase/timeline within is the shape (function/swinlane is ok).

Is there a way to have it please?

Thank

Oonizuk
#2
Latest Visio Guy Articles / Re: Constrain Control Handle t...
Last post by vojo - March 19, 2025, 07:03:36 PM
glad it helped....best of luck
#3
Programming & Code / Re: Python ... again
Last post by Yacine - March 17, 2025, 08:40:49 AM
So, I wrote a small tool to streamline my workflow with Visio P&IDs (https://visguy.com/vgforum/index.php?topic=10679.msg50503).

Initially, I developed it as a Jupyter Notebook, which took me roughly two hours. The solution consisted of exactly four functions.

Finding it worth sharing with you guys, I decided to port it to VBA. Despite knowing what I wanted to achieve and having a rough plan, it took me three days (approximately 24 hours) to complete—with the help of ChatGPT.

Quite a discrepancy.

The final result? 426 lines of VBA code versus just 82 in Python (or even 60 without comments).

You might argue that the VBA version includes a fully-fledged GUI, whereas the Python version doesn't—but that's precisely the point.

A typical Python script could be structured as a CLI (command-line interface) or a GUI application (e.g., using PyQt or Tkinter). However, in a Jupyter Notebook, all the code is directly accessible, allowing you to use the solution interactively, invoking functions as needed.

Another key factor is Python's data structures, which are on a whole different level compared to VBA.

That said, VBA does have one significant advantage: no external dependencies. Everything is integrated within Visio, making it easy to distribute and reuse.
#4
User-submitted Stuff / Re: Extracting Structured Data...
Last post by Yacine - March 17, 2025, 07:20:56 AM
I enhanced a little bit the parsing routines.

Added Name, NameU and Text to the list of special keywords.
E.g. {Text} gets the text of the shape or {NameU} its universal name.

If fieldName = "ID" Then
            result = shp.ID
        ElseIf fieldName = "Name" Then
            result = shp.Name
        ElseIf fieldName = "NameU" Then
            result = shp.NameU
        ElseIf fieldName = "Text" Then
            result = shp.Text
        ElseIf shp.CellExists(fieldName, False) Then
            result = GetCellValue(shp, fieldName, fieldFormat) 'literal cell name
        ElseIf shp.CellExists("prop." & fieldName, False) Then
            result = GetCellValue(shp, "prop." & fieldName, fieldFormat) ' extend to prop
        ElseIf shp.CellExists("user." & fieldName, False) Then
            result = GetCellValue(shp, "user." & fieldName, fieldFormat) ' extend to user
        Else
            ' no match for any variation of fieldName
            If checkAllFields.Value Then ' ommit the shape completely if checkbox AllFields is checked
                inspectShape = ""
                Exit Function
            End If
            result = "#####" ' else assign an error value to the field
        End If

And added Formula and FormulaU to the modifiers.
{LineColor:fu} could now be translated to THEMEGUARD(RGB(255;255;255))

    Select Case LCase(fieldFormat)
        Case "i", "int"
            GetCellValue = CStr(shp.Cells(fieldName).ResultInt(visNoCast, 0))
        Case "u", "iu"
            GetCellValue = CStr(shp.Cells(fieldName).ResultIU())
        Case "f", "formula"
            GetCellValue = shp.Cells(fieldName).Formula
        Case "fu", "formulau"
            GetCellValue = shp.Cells(fieldName).Formula
        Case Else
            GetCellValue = shp.Cells(fieldName).ResultStr("")
    End Select


#5
User-submitted Stuff / Extracting Structured Data fro...
Last post by Yacine - March 16, 2025, 04:51:37 PM
As a process engineer, I frequently work with functional specifications, often requiring data from Visio diagrams. Manually copying shape properties (e.g., tags, functional descriptions) into documents is error-prone and time-consuming.

To solve this, I wrote a small data extraction tool that allows users to:
  • define the data to export and their format
  • select Visio shapes
  • and get automatically a list of data to paste in Excel, a text document, or other tools

What makes it special?
Regular report tools usually export a whole set of data. To use the data, you would then need to find the right items in your list or table. This one is different, you select visually what you need on your drawing and get only data of the selected shapes.

Second feature - The export format is not hard coded, but uses a format string to extract the data.
The tool uses **placeholders in curly braces `{}`** to define how extracted data should be formatted.



The tool takes first the literal value inside the curly braces and retrieves custom cells like "prop.xyz", "user.xyz", but also standard cells like "PinX" or "LineColor".

In its implementation it tries first the literal name ("xyz"), if not found it tries "prop.xyz", if not found it tries "user.xyz". This allows for a lazy definition of the format strings.

And when the cell is still not found, there are two options. Insert an error code "#####", or remove the shape completely from the results list.

In case of ambiguities, the user can get specific by writing prop.xyz or user.xyz (e.g. "prop.LineColor")

Supported Placeholders
  • {ID} → Returns the shape's ID.
  • {prop.SomeProperty} → Extracts data from ShapeSheet "PROP" section.
  • {user.SomeUserCell} → Extracts data from ShapeSheet "USER" section.

Modifiers for Numerical Values:
  • "{prop.Weight:i}" → Interprets the value as an integer.
  • "{prop.Size:u}" → Returns the value in internal Visio units.

Escape Sequences (Special Characters)
To insert newlines or tabs into the output:
  • "\n" → Newline
  • "\t" → Tab

Items separator
A dedicated field let's you define how the results of the different shapes are separated. Default is "\n", a line break.

---

Schema Management – Save & Reuse Your Custom Formats
To avoid re-entering format strings every time, the tool supports schema management:
  • Define a format string and a separator in the tool's input fields
  • Save it as a named schema (e.g., "P&ID Extraction" or "Network Devices").
  • Select & apply the schema for future use.
  • Schemas are stored as text files (`Schemas.txt`) in `%APPDATA%\VisioCollector\`.
  • The tool provides an interface to browse, edit, rename, and delete schemas.
  • You can sort schemas in a listbox and adjust the order manually.

You cannot view this attachment.

Ready to Try?
Would this be useful for your Visio workflows? I'd love to hear your thoughts and possible improvements!

What other use cases do you see? Would you use this in your field?
#6
Latest Visio Guy Articles / Re: Constrain Control Handle t...
Last post by nmxtch - March 16, 2025, 02:33:07 PM
Quote from: vojo on February 10, 2020, 01:56:51 PMWhat people choose to do with it is up them
(some sort of curve fitting around as given shape or user control of some curve creation).

Hey vojo,

Your tip about restricting the control handle to an arc was exactly what I was looking for, after following Visio Guy's tutorial. Just wanted to let you know that your post wasn't a waste.

As for use-case, I use Visio to place cameras over a floor plan of a building. The whole thing started with simple shapes grouped together however other users would frequently distort the shapes through careless resizing.

Over the years, I got fancy with shapes to restrict that and now use control handles to rotate the camera and control the length and angle of the FOV. I used Visio Guy's tutorial on constricting the path of a control handle and your tip to limit the control handle to within a certain angle -- basically, the control handle moves in a quarter-circle arc around the center of the camera body and the width of the FOV follows it.

Thank you to the both of you!!
#7
Programming & Code / Re: Invoking a macro on multip...
Last post by billman - March 14, 2025, 03:42:17 AM
Thanks, Yacine - I'll check them out.
#8
Programming & Code / Re: Invoking a macro on multip...
Last post by Yacine - March 12, 2025, 10:03:09 PM
Hello Billman,

I'm back with my drag&drop shape from a stencil.

The enclosed files (a drawing and the stencil) show different implementation examples.
All open a formless form.
- the first processes all the selected shapes after the push of a button
- the second does the same, but it considers the order in which the shapes are selected
- the third implements a withevents event handler that processes only shapes when the selection changes. It does not need a push of a button. You just enable and disable it by the use of a check box. This way you can seamlessly process all the shapes on your drawing. When you need to interrupt the process, just uncheck the check box.
- the last example is similar to the third, but uses variables to increment values.

I wonder if you can imagine other implementations.
#9
Programming & Code / Re: Invoking a macro on multip...
Last post by billman - March 12, 2025, 06:35:32 PM
thanks again, wapperdude.  I've been using your context-menu method of invoking macros on single specific shapes but wasn't sure if that would translate to a selection containing two or more shapes - hence my question here.  I haven't tested it yet, but I think it will and the code snippet you provided is where I'm headed for processing multiple shapes.

I haven't learned how to add buttons to the ribbon yet, so I've got a learning curve for your first suggestion.  2a) basically looks like adding a button to the sheet, which is useful idea.  2b) is what I'm already doing, though 3) is what I'm really actually doing because the macros I want to run only to some shapes.
#10
Programming & Code / Re: Invoking a macro on multip...
Last post by wapperdude - March 12, 2025, 03:35:53 PM
There are a few of ways to do this.
1) Add a macro that's accessible from the ribbon.  Normal way.  Good method when multiple shapes involved.
2) Add a shape, which when clicked, would execute the macro...two methods to invoke
      a) in shapesheet, add call to run the macro in the Event double click cell.  This is good for a single, specific macro.
      b) add Action menu item to run the macro.  This works well to provide option to choose from more than 1 macro.
3) Add Action menu to all shapes, which allows any shape to invoke the macro.  This is the least favorable method.

The invoked macro ought to have capability to iterate over the selected shapes.  A suggested form is:
Sub FillAll()
    Dim vShp As Visio.Shape
    Dim vSel As Visio.Selection
   
    Set vSel = ActiveWindow.Selection
    Debug.Print vSel.Count
    If vSel.Count > 1 Then
        For i = 1 To vSel.Count
            Set vShp = vSel.Item(i)
            '*** Add code to modify shape params here:
            Debug.Print vShp.Name
        Next
    Else
        'If less than 2 shapes selected, warn and exit
        MsgBox "Select at least 2 shapes.  Try again."
    End If
End Sub

Browser ID: smf (possibly_robot)
Templates: 2: index (default), Recent (default).
Sub templates: 6: init, html_above, body_above, recent, body_below, html_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 2: index.css, responsive.css.
Hooks called: 227 (show)
Files included: 27 - 1055KB. (show)
Memory used: 916KB.
Tokens: post-login.
Cache hits: 11: 0.00076s for 22,828 bytes (show)
Cache misses: 5: (show)
Queries used: 13.

[Show Queries]