Question

The following Visio macro (using VBA) rotates the currently selected shape:

ActiveWindow.Selection.Rotate90

How can I store that shape into a variable? I tried the code below.

Dim s1 as Shape
Let s1 = ActiveWindow.Selection
s1.Rotate90

That code does not compile, it gives me a "argument not optional" error on "Selection".

If I change it to Selection(0) I get the runtime error "Invalid selection identifier".

If I try Selection(1) I get instead "Object variable or With block variable not set", which I'm guessing is VBA's way of complaining that there is only one object in the selection.

Was it helpful?

Solution

You should use Set instead of Let here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top