RobbieC
Active Member
- Joined
- Dec 14, 2016
- Messages
- 376
- Office Version
- 2010
- Platform
- Windows
Hi there, I have a script to insert a picture which resizes it to fit the top into a range (AK8:BT8). This works fine and will name the picture "PeoplePlantPlanDrawing" and retains the orientation and scale when inserted into the range... happy days...
Now, my problem is that the image the user imports may sit better if rotated 90 degrees (or 270 degrees). I have this code which successfully rotates the image, but I cannot get it to retain its position or change size accordingly:
The maximum range I have to fit the image is AK8:BT48 if this helps...
If you can help point out where I'm going wrong, that would be fantastic. Thanks
Now, my problem is that the image the user imports may sit better if rotated 90 degrees (or 270 degrees). I have this code which successfully rotates the image, but I cannot get it to retain its position or change size accordingly:
Code:
Sub rotatePeoplePlantPlanDrawing()
Dim TargetRange As Range, img As Object, t As Double, l As Double, w As Double, h As Double
ActiveSheet.Shapes("PeoplePlantPlanDrawing").Select
Selection.ShapeRange.IncrementRotation 270#
Set TargetRange = ActiveSheet.Range("AK8:BT8")
Set img = ActiveSheet.Shapes("PeoplePlantPlanDrawing")
With TargetRange
t = .Top
l = .Left
w = .width
h = .Height
End With
With img
.Top = t
.Left = l
.Height = h
.width = w
End With
End Sub
The maximum range I have to fit the image is AK8:BT48 if this helps...
If you can help point out where I'm going wrong, that would be fantastic. Thanks