How to insert 3 images into excel with aligning each positions
Thank everyone very much for suggestions
I would like to know the (1) within .Pictures, does 1 represent 1 image to
be selected and deleted? If I have 3 images, then do I need to set (3) with
..Pictures to perform the Delete function?
Thank everyone very much for any suggestions
Eric
Set myPic = ActiveSheet.Pictures(1)
On Error GoTo 0
If Not myPic Is Nothing Then myPic.Delete
"Jacob Skaria" wrote:
Try one by one as below....
'Get the locations
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
'Insert picture
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
'Set location
With myPic
.ShapeRange.LockAspectRatio = msoFalse '/ msoTrue
.Top = dblTop
.Left = dblLeft
.Height = dblHeight
.Width = dblWidth
End With
--
Jacob
"Eric" wrote:
Does anyone have any suggestions on how to insert 3 images into excel with
aligning each positions? Please see following code for detailed description.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric
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")
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic3.JPG")
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic5.JPG")
' I try to insert more code here, but it does not work
Else
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic2.JPG")
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic4.JPG")
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic6.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
'Furthermore, I get no idea on how to align 3 different images from
following code.
With myPic
.ShapeRange.LockAspectRatio = msoFalse '/ msoTrue
.Top = dblTop
.Left = dblLeft
.Height = dblHeight
.Width = dblWidth
End With
End If
End Sub
|