View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
the excel-arator[_2_] the excel-arator[_2_] is offline
external usenet poster
 
Posts: 3
Default InserPictureInRange method for excel VBA

That works well, thanks a lot!

"Ron de Bruin" wrote:

This is not a standard function of Excel

You can also use this

Sub Test()
Dim myPict As Picture
With ActiveSheet.Range("B5")
Set myPict = .Parent.Pictures.Insert("C:\FolderName\PictureFile Name.gif")
myPict.Top = .Top
'myPict.Width = .Width
'myPict.Height = .Height
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"the excel-arator" <the wrote in message
...
I found a snippit of code on an excel help website which is supposed to
insert a picture into a range of cells. However, when the code is run, I get
a compile error saying the sub or function is not defined. Should the code
below work? And if not, does anyone have any ideas on how to insert a picture
into a specified range of cells? The only way I know of is the "addpicture"
method where you have to specify in points where the image is insert, and how
large to make the image.
Using cell references for sizing and placement would be alot easier! I'm new
to VBA, so simplified explanations would be appreciated!

Here's the code I found:

Sub TestInsertPictureInRange()
InsertPictureInRange "C:\FolderName\PictureFileName.gif", _
Range("B5:D10")
End Sub

Thanks for you help!