Inset a picture

O

ordnance1

Is there any way (using code) to insert a picture to a worksheet? I have
tried recording the process but have not been succesful.

I want to insert graphic C:\pictures\Test.gif into cell C3.
 
D

Dave Peterson

Option Explicit
Sub testme01()

Dim myPict As Picture
Dim myPictName As String

myPictName = "C:\test.jpg"

With ActiveSheet
With .Range("c3")
Set myPict = .Parent.Pictures.Insert(Filename:=myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
myPict.Name = "Pict_" & .Cells(1).Address(0, 0)
End With
End With
End Sub

I'm not sure if you want to fix the .width or the .height, though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top