move sub shape at the top left corner of the master shape

Started by kiler40, August 13, 2015, 11:19:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kiler40

Hello Everybody,

I have a routine that drops master shape in a page, but then i need to add another shape inside.
for this i used maybe the most stupid method in the world  8) :
1. drop the second shape
2. cut the second shape
3. drop the "master shape"
4. open master shape group
5. paste the cut second shape

i could not think of anything more good :D

But now i want to have the second shape at the top left corner of the master shape.
I have set the pinX,Y position of the second shape to top-left, but now i cant send the shape to the corner.
Any clues.
I thought to take the ID of the shape

Set shp = Visio.ActiveWindow.Selection(1)
                ID = shp.ID
               
                    If shp.Cells("Width").Formula > "138mm" Then
                        size = shp.Cells("Width")
                        hght = shp.Cells("Height")
                        aspkt = size / (138 / 25.4)
           
                        shp.Cells("width") = size / aspkt
                        shp.Cells("Height") = hght / aspkt
                    End If
                    shp.OpenDrawWindow.Activate
                            Application.ActiveWindow.Shape.Paste
                            Set shp2 = Visio.ActiveWindow.Selection(1)
                             If shp2.CellExists("Prop.connector", 0) Then
                                shp2.Cells("Prop.Connector") = ptnum2
                                shp2.Cells("PinX") = "=Sheet." & ID & "!Width*0"
                                shp2.Cells("PinY") = "=sheet." & ID & "!Height*1"
                            End If


But it is giving me type missmatch and i cannot understand why.

Any help please.

Maybe it is a stupid one... but...

Thanks,
Andrei

Yacine

Yacine

kiler40


Yacine

I guess the reason is that .cells("PinX") - being an object - has a handler that understands that when being assigned to a number, it writes it in the formula, but is not clever enough to do the same with a string.
The solution is to properly address the property of the object:
shp2.cells("PinX").FormulaU = "sheet." & ID & "!Width*0"
Yacine

kiler40

sometimes i really cant understand the things.
I tried this 2 weeks ago when i posted the topic - and no luck

Now it is OK

Anyhow. Thanks again for the help.  8)

Cheers
Andrei