Results 1 to 10 of 10

Insert images permanently

Threaded View

  1. #1
    Banned User!
    Join Date
    04-19-2012
    Location
    Lancaster, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Insert images permanently

    Hi all, I created a macro to insert pictures to Excel from files based on item numbers. Everything works great except every time you open the file, it needs to pull the images from the files. The location is a network drive, so if somebody wants to open the sheet from a location not connected to our network, the images don't display. Is there a way to save the images in the file for good? Ill post my code below.
    THANKS!!!


    Sub getImages()
    '
    ' getImages Macro
    ' gets images
    '
    ' Keyboard Shortcut: Ctrl+i
    Dim sFileName As String
    Dim bContinue As Boolean
    Dim beenHereBefore As Boolean
    Dim i As Integer
    Dim h As Integer
    Dim w As Integer
    Dim t As Integer
    Dim l As Integer
    
    i = 2
    bContinue = True
    
    sFileName = Sheet1.Cells(i, "b")
    
    While bContinue
    
        Sheet1.Cells(i, "a").Select
        Selection.RowHeight = 60
        Selection.ColumnWidth = 17
        h = Selection.Height
        w = Selection.Width
        t = Selection.Top
        l = Selection.Left
        
        
        'select the cell where it should be inserted
        sPath = "\\Pbk3\CounterPointSQL\PrimitivesSQL\ItemImages\" & sFileName & ".jpg"
        ActiveSheet.Pictures.Insert(sPath).Select
        'inserts picture and select it
        
        Selection.ShapeRange.Width = 40
        Selection.ShapeRange.Height = 40
        
    
        
        Selection.ShapeRange.Left = (l + w / 2) - (Selection.ShapeRange.Width / 2)
        Selection.ShapeRange.Top = (t + h / 2) - (Selection.ShapeRange.Height / 2)
              
        
        i = i + 1
        sFileName = Sheet1.Cells(i, "b")
        
        If sFileName = "" Then
            bContinue = False
        End If
    
    Wend
    
    End Sub
    Last edited by davesexcel; 04-19-2012 at 08:50 PM.

Thread Information

Users Browsing this Thread

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

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