+ Reply to Thread
Results 1 to 6 of 6

Modify VBA to insert picture embedded in file instead of a link to a picture

  1. #1
    Registered User
    Join Date
    05-24-2017
    Location
    Milton Keynes
    MS-Off Ver
    Office 2016
    Posts
    10

    Modify VBA to insert picture embedded in file instead of a link to a picture

    Hello all!

    Hoping somebody can help me here, I'm way beyond my knowledge base and out of my comfort zone with this problem!

    I currently use a macro to insert pictures to a specific cell, when I click the assigned button, it opens the file browser, allows me to choose my picture, and then asks to select the cell I wish it to be fitted to, however this works fine until the document leaves my laptop where the pictures are only linked to, instead of being saved with the document.

    I understand this problem is caused by newer versions of excel (circa 2013 onwards?) and that the solution is to change it from a picture insert to a shape insert as a picture, but I cannot get a macro to work with these commands because I do not fully understand them.

    If somebody can guide me on this, that would be much appreciated, I have attached my code used currently below:

    Please Login or Register  to view this content.
    I believe it will then just be this part that needs changing?

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify VBA to insert picture embedded in file instead of a link to a picture

    Try this. It works but I am not able to test whether it is portable to another machine--the documentation says it should be.
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-24-2017
    Location
    Milton Keynes
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: Modify VBA to insert picture embedded in file instead of a link to a picture

    Quote Originally Posted by 6StringJazzer View Post
    Try this. It works but I am not able to test whether it is portable to another machine--the documentation says it should be.
    Please Login or Register  to view this content.
    Thanks Jeff appreciate the reply,

    I just tried it, however when I select the photo, and then the cell in which I wish it to be held, it gives me a run time error "424" with a message saying "object required". If I run the debug part, it highlights your modification yellow? I hope that helps?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify VBA to insert picture embedded in file instead of a link to a picture

    If your code is not in the target worksheet then you will need to qualify it. I don't recommend using ActiveSheet but to be consistent, this change will fix that problem:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Modify VBA to insert picture embedded in file instead of a link to a picture

    I got this from someone somewhere.
    In 2013 it seems to work.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-24-2017
    Location
    Milton Keynes
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: Modify VBA to insert picture embedded in file instead of a link to a picture

    Quote Originally Posted by 6StringJazzer View Post
    If your code is not in the target worksheet then you will need to qualify it. I don't recommend using ActiveSheet but to be consistent, this change will fix that problem:

    Please Login or Register  to view this content.
    Thanks Jeff, that has fixed it.

    Can you elaborate on why it fixed it for my understanding? The object the error was referring to was not the picture itself then, more the destination?

+ 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. [SOLVED] insert picture the same size and location of existing picture
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2015, 11:14 AM
  2. [SOLVED] Open File, Load Picture and on reopen (Initialize) the picture loads.
    By jquintana83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2014, 12:05 PM
  3. VB code to insert picture when email picture not in excel
    By T_BOLT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2014, 06:42 AM
  4. Click on picture and run macro to replace existing picture with selected picture file
    By houseflipsheet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 12:02 AM
  5. VBA for Picture insert at particular worksheet range. Picture name derived from cell.
    By Douglas2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2013, 01:16 AM
  6. Creating macro to insert a picture by including specific picture name & path
    By NissaFrenchRamsteyn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2012, 05:40 AM
  7. [SOLVED] macro: insert picture based on workbook location, not picture root path.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 07:47 AM

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