Originally Posted by
Spielberg
Here's my second post, after amazing replies from some great folks! Thank you all for that.
So, when I insert an image - my img variable preset with the path and filename:
.Rotation and IncrementRotation do not work within the With/End With statements.
Without having to use .Select, is there a way to rotate it?
Mike
.Rotation and IncrementRotation do work, but .ShapeRange is their parent
Option Explicit
Sub test1()
Dim img As String
Dim FY As Long, FX As Long
img = "C:\Users\Daddy\Work\Dilbert Characters\Dilbert JPGs (100x100)\Dogbert.jpg"
FX = 10
FY = 10
With ActiveSheet.Pictures.Insert(img)
.Top = ActiveSheet.Cells(FY, FX).Top
.Left = ActiveSheet.Cells(FY, FX).Left
.ShapeRange.Rotation = 45
End With
End Sub
The easy way to figure out a lot of the object model is to record just a small macro doing manually where I'm stuck and want the macro to do
The recorder is VERY literal and records everything (hard coded cell addresses, Selects, Small Scrolls, ....) so I don't use it's code, but it does point me in the direction
Like below, the .Select and Selection. told me about ShapeRange
Sub Macro3()
'
' Macro3 Macro
'
'
ActiveSheet.Pictures.Insert("C:\Users\Daddy\Work\Dilbert Characters\Dilbert JPGs (100x100)\Dilbert.jpg").Select
Selection.ShapeRange.IncrementLeft 204
Selection.ShapeRange.IncrementTop -87
Selection.ShapeRange.Rotation = 45
End Sub