below is my coding, it inserts a picture into a cell and fits to what ever the cell size is.
my cells are more landscape (fixed) than portrait, how can i still make the images fit into the cell height wise but keep a aspect ratio of a portrait picture if you get me
Sub InsertPicture1()
Dim myPicture As Variant
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", , "Select Picture to Import")
If myPicture = False Then Exit Sub
Application.ScreenUpdating = False
Dim iLeft#, iTop#, iWidth#, iHeight#
With Range("B4")
iLeft = .Left
iTop = .Top
.Select
End With
Set myPicture = ActiveSheet.Pictures.Insert(myPicture)
With Range("b4")
iWidth = .Width: iHeight = .Height
End With
With myPicture
.Width = iWidth: .Height = iHeight
End With
Application.ScreenUpdating = True
Dim octl As CommandBarControl
With Selection
Set octl = Application.CommandBars.FindControl(ID:=6382)
Application.SendKeys "%e~"
Application.SendKeys "%a~"
Application.SendKeys "%w~"
octl.Execute
End With
End Sub
my cells are more landscape (fixed) than portrait, how can i still make the images fit into the cell height wise but keep a aspect ratio of a portrait picture if you get me
Sub InsertPicture1()
Dim myPicture As Variant
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", , "Select Picture to Import")
If myPicture = False Then Exit Sub
Application.ScreenUpdating = False
Dim iLeft#, iTop#, iWidth#, iHeight#
With Range("B4")
iLeft = .Left
iTop = .Top
.Select
End With
Set myPicture = ActiveSheet.Pictures.Insert(myPicture)
With Range("b4")
iWidth = .Width: iHeight = .Height
End With
With myPicture
.Width = iWidth: .Height = iHeight
End With
Application.ScreenUpdating = True
Dim octl As CommandBarControl
With Selection
Set octl = Application.CommandBars.FindControl(ID:=6382)
Application.SendKeys "%e~"
Application.SendKeys "%a~"
Application.SendKeys "%w~"
octl.Execute
End With
End Sub