LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to stretch image cover specific cell?

I have inserted some images into another cells, which is fixed and will not
be changed, because of the code myPic.Delete, which delete every image within
this worksheet. What if I would like to show 2 or 3 images and align each
image into different positions, could you please give me any suggestions on
where I can add the code for addition images?
Thank you very much for any suggestions
Eric

"OssieMac" wrote:

Hi Eric,

Firstly, you may not be able to completely resize the picture because I
think that they retain proportion. With my tesing of the following code the
width seems to take precedence over the height and therefore the top, left
and width were correct but the height was oversize even though the correct
height was calculated.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPic As Object
Dim dblTop As Double
Dim dblLeft As Double
Dim dblHeight As Double
Dim dblWidth As Double

If Target.Address = "$A$1" Then
On Error Resume Next
Set myPic = ActiveSheet.Pictures(1)
On Error GoTo 0
If Not myPic Is Nothing Then myPic.Delete

If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic2.JPG")
End If

dblTop = Cells(10, "B").Top
dblLeft = Cells(10, "B").Left
dblHeight = Cells(14, "B").Top - Cells(10, "B").Top
dblWidth = Cells(10, "D").Left - Cells(10, "B").Left

With myPic
.Top = dblTop
.Left = dblLeft
.Height = dblHeight
.Width = dblWidth
End With

End If

--
Regards,

OssieMac


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Stretch While Printing ironhydroxide Excel Programming 2 June 6th 09 09:25 PM
Image Stretch On Printouts and Print Prieview ironhydroxide Excel Discussion (Misc queries) 0 May 29th 09 09:47 PM
display image when specific value in a cell exist nicosalt Excel Discussion (Misc queries) 1 April 7th 06 07:55 PM
Insering an image on a specific cell Moiz Excel Programming 1 December 10th 05 10:56 AM
How do I insert an image into a specific cell within a protected . Scott Peebles Excel Discussion (Misc queries) 1 January 7th 05 01:14 AM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"