Embed Image to Excel Spreadsheet - VBA

后端 未结 2 1632
予麋鹿
予麋鹿 2020-12-03 19:47

I need to embed an image to a spreadsheet via Excel VBA, such that whenever I relocate my excel file, the image will still show up. How can I do this?

2条回答
  •  孤街浪徒
    2020-12-03 19:48

    This code will insert an image on the current sheet and position it at at cell E10:

    Set oPic = Application.ActiveSheet.Shapes.AddPicture("d:\temp\mypic.jpg", False, True, 1, 1, 1, 1)
    oPic.ScaleHeight 1, True
    oPic.ScaleWidth 1, True
    
    oPic.Top = Range("E10").Top
    oPic.Left = Range("E10").Left
    

提交回复
热议问题