+ Reply to Thread
Results 1 to 2 of 2

VBA Macro to fetch images based on URLs in sheet

Hybrid View

jhodges VBA Macro to fetch images... 07-13-2010, 10:00 AM
jhodges Re: VBA Macro to fetch images... 07-14-2010, 08:38 AM
  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    Newport, Rhode Island
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question VBA Macro to fetch images based on URLs in sheet

    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
    Last edited by jhodges; 07-13-2010 at 10:25 AM.

  2. #2
    Registered User
    Join Date
    07-13-2010
    Location
    Newport, Rhode Island
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VBA Macro to fetch images based on URLs in sheet

    !BUMP!

    Any ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1