image insertion height problem

T

thomas donino

So far this post has gotten no replies on mrexcel so I post here as well
hoping for some help


The code below sets the range where i want the image to reside and correctly
inserts the image to the range a1:f1 except the height. The image bottom edge
is down at row 4 instead of the bottom of row 1 which i have set the pixel
height before insertion.

Any idea how to set the height properly so it only covers the a1:f1 range?




Sub Test()
'***Change to suit
Const PicName As String = "X:\slksdffsldkfslhf .jpg"
Dim Pic As Object
Set Pic = ActiveSheet.Pictures.Insert(PicName)
ActiveSheet.Select
Rows("1:1").RowHeight = 69
Range("A1:F1").Select
Application.CutCopyMode = False
Selection.Merge True
With Pic
..Top = Range("A1").Top
..Left = Range("A1").Left
..Height = Range("A1").RowHeight 'need to fix this
..Width = Range("A1:F1").Width
End With
End Sub
__________________
Thomas Donino
BATL Management LP
 
P

Patrick Molloy

thsi worked fine for me:

Sub Macro1()

Dim pic As Object

Set pic = ActiveSheet.Pictures.Insert( _
"C:\Documents and Settings\All Users\Documents\My Pictures\Sample
Pictures\Winter.jpg" _
)
With Range("D5:G5")
pic.Top = .Top
pic.Left = .Left
pic.Width = .Width
pic.Height = .Height
End With
End Sub
 
T

thomas donino

Thank you I will try recoding in that manner

Patrick Molloy said:
thsi worked fine for me:

Sub Macro1()

Dim pic As Object

Set pic = ActiveSheet.Pictures.Insert( _
"C:\Documents and Settings\All Users\Documents\My Pictures\Sample
Pictures\Winter.jpg" _
)
With Range("D5:G5")
pic.Top = .Top
pic.Left = .Left
pic.Width = .Width
pic.Height = .Height
End With
End Sub
 

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