View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Resize the image in excel 2007

I tested this in xl2007 and the code put the picture entirely in the
activecell. Isn't that what you want? The size of the cell determines the size
of the picture??????

(Same code with all the declarations.)

Option Explicit
Sub GetPhotoone()

Dim rng As Range
Dim myPictName As String
Dim myPict As Picture

Set rng = ActiveCell
myPictName = Activecell.Value

Set myPict = ActiveSheet.Pictures.Insert(Filename:=myPictName)

myPict.Top = rng.Top
myPict.Left = rng.Left
myPict.Width = rng.Width
myPict.Height = rng.Height
myPict.Name = "Pict_" & Cells(1).Address(0, 0)

End Sub




Akader wrote:

thank s Dave

same problem for this code also, it's only adjust Height size , i need from
the code to adjust the Width & Height dynamically same as the row & column
size


"Dave Peterson" wrote:

You may want to just include the part of the code that actually matters to see
if that helps.

(Untested)

Option Explicit
Sub GetPhotoone()

Dim rng As Range

Set rng = ActiveCell
myPictName = rng.Value

Set myPict = .Parent.Pictures.Insert(Filename:=myPictName)

myPict.Top = rng.Top
myPict.Left = rng.Left
myPict.Width = rng.Width
myPict.Height = rng.Height
myPict.Name = "Pict_" & .Cells(1).Address(0, 0)

End Sub


Rng was set to the activecell. All that other stuff didn't really matter (and
didn't compile for me in xl2003).




--

Dave Peterson