+ Reply to Thread
Results 1 to 2 of 2

Insert Dynamically in Excel using image from server path

  1. #1
    Registered User
    Join Date
    08-17-2018
    Location
    Houston, tx
    MS-Off Ver
    Office 2013
    Posts
    1

    Insert Dynamically in Excel using image from server path

    I have code below to look for an image of a sku in a specific folder in our server and insert /autosize - but the issue i have is that if I send this spreadsheet to anyone else not on the server, they cannot see images. Can someone help fix this so it inserts the image dynamically? I believe this is what has to be done to place the actual image in the sheet rather than link-back when the sheet is updated/Opened. Or, how can I format this to send out and include images if they are not linked to the server? I have looked at other posts which refer to inserting dynamically but I cant get anything to work

    Sub Imageupdate()
    ' inserts the picture files listed in col A into the workbook,
    ' and sizes and centers in col B

    Const sPath As String = "S:\Images\Casio\"
    'Const sPath As String = "C:\Users\shg\Pictures\shg"
    Dim cell As Range
    Dim sFile As String
    Dim oPic As Picture

    For Each cell In Range("A2", Cells(Rows.Count, "A").End(xlUp))
    sFile = sPath & cell.Text & ".jpg"
    If Len(Dir(sFile)) Then
    Set oPic = ActiveSheet.Pictures.Insert(sFile)
    oPic.ShapeRange.LockAspectRatio = msoTrue

    With cell.Offset(, 1)
    If oPic.Height > .Height Then oPic.Height = .Height
    If oPic.Width > .Width Then oPic.Width = .Width

    oPic.Top = .Top + .Height / 2 - oPic.Height / 2
    oPic.Left = .Left + .Width / 2 - oPic.Width / 2
    End With
    Else
    cell.Select
    MsgBox sFile & " not found"
    End If
    Next cell
    End Sub

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Insert Dynamically in Excel using image from server path

    Instead of the:
    Please Login or Register  to view this content.
    , use the:
    Please Login or Register  to view this content.
    where:
    Filename:=sFile
    LinkToFile:=msoFalse
    SaveWithDocument:=msoTrue

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to cut image file path from word bookmark and replace with inserted image
    By JayRay1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2018, 07:31 PM
  2. Insert Image With Image Filename In Another Cell - Excel
    By Angelq117 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2016, 09:38 AM
  3. [SOLVED] Insert jpg image from file path to image frame
    By SAsplin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-27-2012, 10:12 AM
  4. Replies: 0
    Last Post: 06-11-2012, 10:58 AM
  5. Displaying and Updating Image Dynamically (ActiveX Image Control?)
    By VTHokie11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2011, 10:57 AM
  6. Server name in Excel file path
    By John Mansfield in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2006, 12:25 PM
  7. [SOLVED] How do I use a server name in an Excel chart file path?
    By Zimtok5 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-25-2005, 10:05 PM

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