0

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

            With wb.Sheets(1).Pictures.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
2
  • Not sure what you are asking? Does code you posted not work correctly? Commented Sep 13, 2011 at 20:09
  • Try a Google search for: "insert image into a cell excel vba". Tons of info out there. Commented Sep 13, 2011 at 20:43

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.