I'm trying to get images into the cells next to the URL's in my sheet so that I can more easily check to make sure that everything is correct on a data entry thing I'm doing. I have been piecing together code and I ran into a bit of a wall. I have never really been able to do cell ranges and stuff correctly but I basically just need the module to run on every URL in the column and put the images into the cell just to the right of that column.
Function URLTHING()
Dim URL As String
Dim sh As Object
URL = Worksheets("All").Range("H4").Value
Range("I4").Select
' ActiveSheet.Pictures.Insert(URL).Select
ActiveSheet.Select
Range("I4").Select
sImageToLoad = URL
Set sh = ActiveSheet.Pictures.Insert(sImageToLoad)
sh.Select
Debug.Print TypeName(sh), TypeName(Selection)
Selection.ShapeRange.ScaleWidth 0.05, _
msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.05, _
msoFalse, msoScaleFromTopLeft
End Function
It goes and fetches the image then scales it down to 5% because they start out pretty big, is there a way to scale them to a specific size that anyone knows of?
If the code could be changed to use ActiveSheet and ActiveColumn and ActiveCell (or whatever those really are) it would be awesome.
EDIT:
Just did some more coding and improved the image scaling a bit with something I remembered.
Function URLTHING()
Dim URL As String
Dim sh As Object
URL = Worksheets("All").Range("H5").Value
Range("I5").Select
URL = URL + "&hei=100&wid=100&qlt=100"
' ActiveSheet.Pictures.Insert(URL).Select
ActiveSheet.Select
Range("I5").Select
sImageToLoad = URL
Set sh = ActiveSheet.Pictures.Insert(sImageToLoad)
sh.Select
Debug.Print TypeName(sh), TypeName(Selection)
Selection.ShapeRange.ScaleWidth 0.4, _
msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.4, _
msoFalse, msoScaleFromTopLeft
End Function
One last thing.... being able to center that image in the cell would be awesome.
-- Thanks
Bookmarks