Sub UnlockAspectRatioAndResize()

Dim shp As Shape

For Each shp In ActiveSheet.Shapes
    shp.LockAspectRatio = msoFalse 'Unlock aspect ratio
    
    If shp.Left >= Range("L9").Left And shp.Top >= Range("L9").Top And _
       shp.Left + shp.Width <= Range("L16").Left + Range("L16").Width And _
       shp.Top + shp.Height <= Range("L16").Top + Range("L16").Height Then 'Check if shape is within the specified range
       
        shp.Left = Range("L9").Left + (Range("L9").Width - shp.Width) / 2 'Reposition shape to center of cell
        shp.Top = Range("L9").Top + (Range("L9").Height - shp.Height) / 2
        shp.Width = 87.874015748 'Set new height and width
        shp.Height = 87.874015748
        
    End If
    
Next shp

End Sub


原文地址: https://www.cveoy.top/t/topic/bazy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录