tags:

views:

130

answers:

1

I am a total beginner here, so this is probably something simple I'm overlooking.

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

ActiveWindow.Selection.Rotate90

My question: how can I store that shape into a variable? I tried the code below and don't know how to change it to make it work.

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

That code does not even 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.

The built-in help for that particular error does not help me. There is one google hit for that error message but it leaves me more confused than before, not less.

Bonus question: can I use C# instead of VBA to extend Visio? And if so, how?

+1  A: 

You should use Set instead of Let here.

Beatles1692
indeed, that fixed it! Thanks!
redtuna