VBA code to display the four 1-D Endpoint formulas for a selected shape

Started by PinPinPoola, September 02, 2021, 11:22:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PinPinPoola

Hello again,

Cheeky request as I am struggling to get my non-programmer head wrapped around VBA coding.

I would like to be able to select a single shape and run a VBA macro (via a keyboard shortcut) to display it's four 1-D endpoint formulas in a popup or on a text box created on the same page, so I could then copy the text into another app.


BeginX: =PAR(PNT('7014-S25 Rack'!Connections.X13,'7014-S25 Rack'!Connections.Y13))
BeginY: =PAR(PNT('7014-S25 Rack'!Connections.X13,'7014-S25 Rack'!Connections.Y13))
  EndX: =PAR(PNT('7014-S25 Rack'!Connections.X14,'7014-S25 Rack'!Connections.Y14))
  EndY: =PAR(PNT('7014-S25 Rack'!Connections.X14,'7014-S25 Rack'!Connections.Y14))

Any help or pointers will be gratefully received.

Many Thanks
Pin

Surrogate

Hi, Pin !

Sub bbb()
Dim sh As Shape     ' selected rectangle
Dim txt As String   ' text for new shape
Dim nsh As Shape    ' new shape
Set sh = ActiveWindow.Selection.PrimaryItem
txt = "BeginX: =" & sh.Cells("BeginX").FormulaU & Chr(10) & _
    "BeginY: =" & sh.Cells("BeginY").FormulaU & Chr(10) & _
    "EndX: =" & sh.Cells("EndX").FormulaU & Chr(10) & _
    "EndY: =" & sh.Cells("EndY").FormulaU
Set nsh = ActivePage.DrawRectangle(0, 0, 10, 2)
nsh.Text = txt
End Sub
this example add new shape !
Quote from: PinPinPoola on September 02, 2021, 11:22:24 AM
to display it's four 1-D endpoint formulas in a popup
You cant copy text from Msgbox.

PinPinPoola

Thank you @Surrogate

This is perfect. Once again, I really appreciate your help.

How long have you been writing VBA code? Do you have any book or website suggestions for an absolute beginner to start to learn the basics of writing in VBA?

Cheers,
Pin


Surrogate

Quote from: PinPinPoola on September 02, 2021, 12:13:58 PM
How long have you been writing VBA code? Do you have any book or website suggestions for an absolute beginner to start to learn the basics of writing in VBA?
I became VBA-coder in 2010, my first question
Quote from: PinPinPoola on September 02, 2021, 12:13:58 PMDo you have any book or website suggestions for an absolute beginner to start to learn the basics of writing in VBA?
The best book is MS Visio 2003 Developer's Survival Pack
Mastering Data Visualization with Microsoft Visio Professional 2016 by David Parker.
PS But you must also know ShapeSheet, because almost all operations with shapes or pages lead to changes in their property tables.
Please download this package there is 3 MS Word documents: 1st about ShapeSheet and 3rd about VBA.
I embedded these documents in Russian Visio Forum in post (you can look it there).

It's sad that there is no such possibility of embedding documents, videos, etc.
A lot of helpful hyperlinks about Visio - this resource in Russian language, but hyperlink opened via Google Translate service.

melonblobber

Hi Surrogate,

Do you know if there is any way to read the beginX/Y endX/Y from a connect object?

I'm trying on reading a visio schematics, and it's required to read which of the port a connector is linked to. Thanks in advance for any suggestions! ;)

Thankfully,
Mblobber

Surrogate

Hi, melonblobber!
Quote from: melonblobber on December 09, 2021, 10:13:49 AM
Do you know if there is any way to read the beginX/Y endX/Y from a connect object?
Try use properties FromPart or/and ToPart.

melonblobber

Quote from: Surrogate on December 09, 2021, 10:58:40 AM
Hi, melonblobber!
Quote from: melonblobber on December 09, 2021, 10:13:49 AM
Do you know if there is any way to read the beginX/Y endX/Y from a connect object?
Try use properties FromPart or/and ToPart.

Hi Surrogate,

Thanks again foir the suggestions.

I have tried the from/topart command, the problem for me is that the these commands won't return the connection point number. I tried to apply CellsSRC on connect object, since it has Begin/EndX formula showing like Y1, Y2... of shape connection point. Do you know if there is a way to find out which connecters is hooked to which connection point of a shape?

Best,
Mblobber


Surrogate

Quote from: melonblobber on December 10, 2021, 03:13:05 AMDo you know if there is a way to find out which connecters is hooked to which connection point of a shape?
Do you need read connection point coordinates or shape names (or something else) ?