开发者

Excel 2007 Display image from image path?

I would like to insert an image into a cell. The code below inserts it into a sheet:

            With wb.Sheets(1).P开发者_Python百科ictures.Insert("\\bk01fil0001\salesdb$\ImageUpload\NoImage.gif")
            .Left = wb.Sheets(1).Range("B2").Left
            .Top = wb.Sheets(1).Range("B2").Top
            .Width = wb.Sheets(1).Range("B2").Width
            End With


You can't insert a picture inside a cell: they always sit "on top" of the worksheet. Best you can do is position it over the required cell/range as you are already doing.


You can make things a little simpler by selecting a cell then inserting the picture...

Sheets(1).Select
Range("B2").Select
ActiveSheet.Pictures.Insert("\\bk01fil0001\salesdb$\ImageUpload\NoImage.gif")

I don't think this would ever be a less efficient method as you would only ever wish to insert a picture on a visible sheet. I do not see you would need to select the sheet more than once, if at all

(As an aside, it sounds as though you are trying to auto-insert images in one column of a table in which case I would strongly recommend using Cells notation as described in the text accompanying this Excel Visual Basic video)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜