• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How add photo using vba macro

webmax

Member
Hi
i need the macro that if i add the add button in the sheet1 i get the file from the computer and save it in the sheet 2 page appropriate place given.

regards
Shahul
 

Attachments

  • add photo.xls
    33 KB · Views: 8
Check with it....

Code:
Sub Button1_Click()
Dim w As Worksheet
Set w = Sheet2
   With w.Pictures.Insert("C:\test.jpg")
        With .ShapeRange
            .LockAspectRatio = msoFalse
            .Height = w.Shapes("Rectangle 1").Height '75
            .Width = w.Shapes("Rectangle 1").Width '95
        End With
        .Left = w.Shapes("Rectangle 1").Left
        .Top = w.Shapes("Rectangle 1").Top
        .Placement = 1
        .PrintObject = True
    End With
End Sub
 
Check with it....

..............

Code:
Sub Button1_Click()
Dim o As Shape, pic As String
Set o = Sheet2.Shapes("Rectangle 1")
pic = "C:\Users\Deepak\Pictures\may_poster_14_X_19_inch.jpg"
   With Sheet2.Pictures.Insert(pic)
        With .ShapeRange
            .LockAspectRatio = msoFalse
            .Height = o.Height '75
            .Width = o.Width '95
        End With
        .Left = o.Left
        .Top = o.Top
        .Placement = 1
        .PrintObject = True
    End With
End Sub
 
hi deepak.
the below part the same will come in the get picture of the contains extension of jpg or png
pic = "C:\Users\Deepak\Pictures\may_poster_14_X_19_inch.jpg"
 
Back
Top