set rectangle name

Started by pcoz, September 10, 2015, 11:08:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pcoz

Hi,

If I draw a rectangle this is assigned an incremental id, e.g.
    Application.ActiveWindow.Page.DrawRectangle 3, 10.2, 4.3, 9.5   'will be assigned shape id 1
    Application.ActiveWindow.Page.DrawRectangle 1, 9.2, 2.3, 8.5    'will be assigned shape id 2
    Application.ActiveWindow.Page.DrawRectangle 3, 9.2, 4.3, 8.5    'will be assigned shape id 3

Is there any way I can draw a rectangle and assign a name to it when I draw it without having to select it first?

Thanks :-)

Paul Herber

dim shp as shape
shp = Application.ActiveWindow.Page.DrawRectangle 3, 9.2, 4.3, 8.5
shp.Name = "fred"
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

pcoz

Thanks

Visio didn't like
shp = Application.ActiveWindow.Page.DrawRectangle 3, 9.2, 4.3, 8.5
(font changed to red and error: expected end of statement)

:-)

Paul Herber

Ah yes, sorry, I don't normally do VBA,
Set shp = Application.ActiveWindow.Page.DrawRectangle 3, 9.2, 4.3, 8.5
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

pcoz

Thanks

For some reasons VBA needs brackets when using Set
Set shp = Application.ActiveWindow.Page.DrawRectangle(1, 9.2, 2.3, 8.5)

:-)

wapperdude

#5
Visio 2019 Pro