ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inset a picture (https://www.excelbanter.com/excel-programming/420062-inset-picture.html)

ordnance1

Inset a picture
 
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.

Simon Lloyd[_928_]

Inset a picture
 

One way is:

Range("C3").Select

ActiveSheet.OLEObjects.Add(Filename:="C:\Users\xxx \Documents\xxx.jpg", _
Link:=False, DisplayAsIcon:=False).Select


--
Simon Lloyd

Regards,
Simon Lloyd
'www.thecodecage.com' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=29833


Charlotte E.[_2_]

Inset a picture
 
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.



This one is actually pretty cool:

http://www.EXCELGAARD.dk/Lib/PictureCell/


CE



Dave Peterson

Inset a picture
 
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.

ordnance1 wrote:

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.


--

Dave Peterson


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com