Here's macro that will center and re-size the pic to fit into the container. This is minimalist code. It assumes that ideally there is only one container on the page, or at least, the 1st container that the macro finds is the desired container. Next, it presumes that the container has been locked and will not adjust size to fit the shape. Basically, then, it assumes that the container has been preset and locked, ready for the picture. The container should not be selected.
The process begins by dropping the picture on the page, anywhere. Doesnot have to be on or near the container. Just leave it selected and then run the macro. In my case, the image was rotated 90 degrees. You should either comment the rotation line in the macro or set to a desired value. Also, the picture size is hard coded to be 6x8. Note, width and height are reversed in the test case due to the 90 degree rotation.
Sub ctrXpd()
Dim vCntr As Visio.Shape 'variable for container
Dim vImg As Visio.Shape 'variable for picture
Set vImg = ActiveWindow.Selection(1)
vImg.CellsSRC(visSectionObject, visRowLock, visLockAspect).FormulaU = "1"
vImg.Cells("Angle").Formula = "-90 deg" 'May need to comment out this line
vImg.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = "8 in" 'May need to reverse these values
vImg.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = "6 in"
ActiveWindow.DeselectAll
For Each vCntr In ActivePage.Shapes
If vCntr.CellExists("User.msvStructureType", 0) Then 'simple test to see if shape is a container
cntrPinX = vCntr.Cells("PinX").ResultStr(visNone)
cntrPinY = vCntr.Cells("PinY").ResultStr(visNone)
vImg.Cells("PinX").Formula = cntrPinX
vImg.Cells("PinY").Formula = cntrPinY
ActiveWindow.Zoom = -1
Exit Sub
End If
Next
End Sub