none
Inserting a Picture Into A Workbook From a VBA Form RRS feed

  • Question

  • I have some code which has worked fine up until today and I have no idea why?

    The idea is to click a button on the VBA form, select an image, it embeds itself on to the form and automatically embeds itself in a specific location on a worksheet.

    I get "Run time error 1004, cannot insert object"

    Here is the code:

    Dim shpPicture As OLEObject
       
        With Worksheets("Final Report")
            Set shpPicture = .OLEObjects.Add(ClassType:="Forms.Image.1", _
                            Link:=False, _
                            DisplayAsIcon:=False, _
                            Left:=.Cells(28, "D").Left, _
                            Top:=.Cells(28, "D").Top, _
                            Width:=Me.RRPPicture.Width, _
                            Height:=Me.RRPPicture.Height)
        End With

    Any help would be greatly appreciated....

    Thursday, April 23, 2015 1:34 PM

All replies

  • It works fine for me, albeit with some hard values for width and height. Is your sheet protected perhaps?
    Thursday, April 23, 2015 4:00 PM
    Moderator
  • Hi MrsMaker,

    The code is ok.

    Could you reproduce that issue in a new file? If so, please share sample file on the OneDrive.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 24, 2015 6:05 AM
    Moderator
  • I have uploaded to one -drive but it won't let me insert a hyperlink due to account verification?? Is there another way to get a link to you?

    Many thanks in advance,

    Wednesday, April 29, 2015 10:28 AM
  • I have uploaded to one -drive but it won't let me insert a hyperlink due to account verification?? Is there another way of getting this to you?

    Many thanks

    Wednesday, April 29, 2015 10:29 AM
  • I have now added a link address to my Biography, password for worksheet and VB code = mistycarrot469
    Wednesday, April 29, 2015 10:37 AM
  • Hi MrsMaker,

    You could parse the hyperlink here, then select it and click Remove Hyperlink (Ctrl + Shift + K) to let it show as normal text.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 30, 2015 6:42 AM
    Moderator