+ Reply to Thread
Results 1 to 5 of 5

Keep images in an excel sheet while removing their link

  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    3

    Keep images in an excel sheet while removing their link

    I'm new to this forum and looked for an answer for my issue. Found a reply that I thought would fix it but not really...
    I have a sheet with hundreds of images that are copied in a cell via a macro. The macro looks into a folder of images, ties the right image to the an item code and resizes the image to fit the cell. Working great!
    I'm trying now to remove the links from the images in this sheet so that every image is part of the sheet and is not referred to via a link. The purpose for that is to be able to share the excel file without having to share the folder with all the images as well. Somehow the link remains active even if I run a macro to remove all links in the sheet. When I remove the folder and re-open the sheet, no images are shown. I just see square boxes with a comment that the link is pointing to a folder where the
    Related image cannot be found...

    Any solutions?

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Keep images in an excel sheet while removing their link

    Post your current macro.
    Gary's Student

  3. #3
    Registered User
    Join Date
    10-23-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Keep images in an excel sheet while removing their link

    Dear Jacobshavn,

    Please see below.

    Macro - Link removal (not working on Microsoft Office Professional Plus 2010)



    Sub DeleteObjectHyperlinks()

    With ActiveSheet

    For Each Shape In .Shapes

    .Hyperlinks.Delete

    Next Shape

    End With

    End Sub


    Macro - Insert pictures from folder and adjust size to fit the cell. (Working fine)



    Sub addPictures()

    Dim pictureFolder As String

    Dim picLocation As String

    Dim startrow As Integer, codeCol As Integer, pictureCol As Integer, blank As Boolean

    pictureFolder = "C:\Users\103018164\Documents\Netherlands Sales Office\Pricing\IMAGE_FILE_LOW\"

    startrow = 12

    codeCol = 2

    pictureCol = 1

    blank = False

    Do

    If IsEmpty(Cells(startrow, codeCol)) Then

    blank = True

    Else

    picLocation = pictureFolder & Cells(startrow, codeCol) & ".jpg"

    InsertPicture picLocation, Cells(startrow, pictureCol), True, True

    Cells(startrow, pictureCol).Select

    End If

    startrow = startrow + 1

    If startrow > 4064 Then Exit Do

    Loop

    End Sub

    Sub InsertPicture(PictureFileName As String, TargetCell As Range, _

    CenterH As Boolean, CenterV As Boolean)

    ' inserts a picture at the top left position of TargetCell

    ' the picture can be centered horizontally and/or vertically

    Dim p As Object, t As Double, l As Double, w As Double, h As Double

    ' Check for valid parameters

    If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub

    If (Dir(PictureFileName) = "") Then Exit Sub

    ' MsgBox "|" & Dir(PictureFileName) & "|"

    ' import picture

    Set p = ActiveSheet.Pictures.Insert(PictureFileName)

    p.Select

    With Selection.ShapeRange

    .LockAspectRatio = msoTrue

    If .Width > .Height Then

    .Width = TargetCell.Width

    If .Height > TargetCell.Height Then .Height = TargetCell.Height

    Else

    .Height = TargetCell.Height

    If .Width > TargetCell.Width Then .Width = TargetCell.Width

    End If

    End With

    If Dir(PictureFileName) = "" Then Exit Sub

    ' resize picture

    p.Select

    With Selection.ShapeRange

    .LockAspectRatio = msoTrue

    If .Width > .Height Then

    .Width = TargetCell.Width

    If .Height > TargetCell.Height Then .Height = TargetCell.Height

    Else

    .Height = TargetCell.Height

    If .Width > TargetCell.Width Then .Width = TargetCell.Width

    End If

    End With

    ' determine positions

    With TargetCell

    t = .Top

    l = .Left

    If CenterH Then

    w = .Offset(0, 1).Left - .Left

    l = l + w / 2 - p.Width / 2

    If l < 1 Then l = 1

    End If

    If CenterV Then

    h = .Offset(1, 0).Top - .Top

    t = t + h / 2 - p.Height / 2

    If t < 1 Then t = 1

    End If

    End With

    ' position picture

    With p

    .Top = t

    .Left = l

    End With

    ' set picture properties

    With Selection

    .Placement = xlMoveAndSize

    .PrintObject = True

    End With

    Set p = Nothing

    End Sub

  4. #4
    Registered User
    Join Date
    05-08-2013
    Location
    Monterey, California
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Keep images in an excel sheet while removing their link

    Check this out:

    http://social.msdn.microsoft.com/For...-?forum=isvvba

    I too am strugging with an insert images macro..

  5. #5
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Keep images in an excel sheet while removing their link

    Its just a matter of how the pictures are added:

    Please Login or Register  to view this content.
    The first TriState is LinkToFile

+ 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. Reducing file size after removing images
    By 6StringJazzer in forum Excel General
    Replies: 0
    Last Post: 12-07-2011, 02:37 PM
  2. Removing images overlapped beyond count in excel sheet
    By coool_tarun in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-14-2011, 06:20 AM
  3. Saving images in an excel sheet
    By gm13958 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2011, 03:46 PM
  4. Removing images in a range
    By GBoy in forum Excel General
    Replies: 8
    Last Post: 04-09-2007, 08:31 PM
  5. [SOLVED] delete images in an excel sheet
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2006, 01:55 PM

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