Zafar Iqbal
Zafar Iqbal

Reputation: 45

Excel Macro to paste ROTATED pictures in Cell comments

This Excel macro is to paste pictures in Excel cell comments. It is working fine. Now, I need a change in it. Pictures should be rotated 270 degree & then pasted in cell comments. When I tried .Comment.Shape.Rotation = 270 it failed and sent run time error '70' "Permission Denied". ". I think picture should be pasted & ROTATED at some temporary location or in memory and then called back & pasted in cell comment. I have +600 picture and their manual rotation is big task in very limited time. Please help in this matter. Thanks

Sub InsertPictures()
    Dim rCell As Range
    Dim RNG As Range
    Dim strPath As String
    strPath = "C:\Users\Public\Pictures\Sample Pictures"
    With Sheets("Sheet1")
        Set RNG = Range("A2:A600")
    End With
    For Each rCell In RNG
        If Dir$(strPath & "\" & cll.Value & ".jpg") <> "" Then
            With cll
                .ClearComments
                .AddComment ("")
                .Comment.Shape.Fill.UserPicture (strPath & "\" & cll.Value & ".jpg")
                .Comment.Shape.Height = 160
                .Comment.Shape.Width = 120
        '.Comment.Shape.Rotation = 270   'Got Error Message "Permission Denied"
                .Comment.Shape.LockAspectRatio = msoTrue
                End With
        End If
    Next rCell
End Sub

Upvotes: 1

Views: 1061

Answers (1)

Liniel
Liniel

Reputation: 729

It is not vba solution, but could be helpful. Use Infranview. This application can rotate all pictures in folder by one click. File-> Batch Conversion/Rename...

Upvotes: 1

Related Questions