+ Reply to Thread
Results 1 to 8 of 8

Macro for inserting images

  1. #1
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Macro for inserting images

    I am running XP using Excel 2007. I have a spreadsheet with 10 worksheets -- each worksheet has anywhere from 10 to 80 one page reports. The top half of each page has a place for a jpg map to be inserted. There are a total of 334 images to be inserted.

    On each page there is a cell that has a "Key" number. That key number is also the name of the jpg. The process works like this:

    1. select the key
    2. move the cursor to the cell below
    3. go to insert picture, paste key
    4. insert picture
    5. select picture, edit picture by changing size to 50%
    6. move to the right 4 clicks and down 10 clicks (to center it)
    7. done

    I can record the macro ok. However, when I move to the next page and put select the cell with the next key, then the macro returns to the first cell where I started (and recorded from).

    When I recorded it with "Use Relative References" the recording only recorded the first 2 steps (1 and 2 above). None of the rest of the steps were recorded.

    Any ideas?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,086

    Re: Macro for inserting images

    Can you post a (sample) workbook, the code and an image file that you are working with.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Re: Macro for inserting images

    Quote Originally Posted by TMShucks View Post
    Can you post a (sample) workbook, the code and an image file that you are working with.

    Regards
    I have tried to upload a 1.29mb zip file multiple times -- but I keep getting a database error.

    If you post an email address I'll email it to you.

  4. #4
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Re: Macro for inserting images

    I just noticed the link possibility. Go here: http://www.curtwatke.com/downloads/Desktop.zip to download. Thanks.

  5. #5
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Re: Macro for inserting images

    Quote Originally Posted by watkec View Post
    I just noticed the link possibility. Go here: http://www.curtwatke.com/downloads/Desktop.zip to download. Thanks.
    For some reason the macro that I recorded did not record each of the steps. I tried several times (which you will see in the attached file). I really do need help on this -- I just can't seem to figure it out.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Macro for inserting images

    Maybe update your example to explain what it is supposed to do, then delete evrything that has nothing to do with your question and attach the workbook again.

  7. #7
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Re: Macro for inserting images

    Quote Originally Posted by davesexcel View Post
    Maybe update your example to explain what it is supposed to do, then delete evrything that has nothing to do with your question and attach the workbook again.
    I found another approach that I am trying. I need a macro to look up the name of the file in column O and then look up the location to insert the file in column N, and then go to a folder and get the picture, and then insert the picture (resized) in the location in column C that is listed in column N and then repeat the process.

    I tried to adapt the previous macro that someone else posted, but I get this error when it runs:

    Run-time error '1004'
    Application-defined or object-defined error

    Here is the macro:

    Please Login or Register  to view this content.
    You can download the new zip file at: http://www.curtwatke.com/downloads/Desktop.zip
    Last edited by davesexcel; 12-10-2010 at 06:12 AM. Reason: Code tags required, why not read the Forum Rule?

  8. #8
    Registered User
    Join Date
    10-28-2007
    Posts
    21

    Re: Macro for inserting images

    Quote Originally Posted by watkec View Post
    I found another approach that I am trying. I need a macro to look up the name of the file in column O and then look up the location to insert the file in column N, and then go to a folder and get the picture, and then insert the picture (resized) in the location in column C that is listed in column N and then repeat the process.

    I tried to adapt the previous macro that someone else posted, but I get this error when it runs:

    Run-time error '1004'
    Application-defined or object-defined error

    Here is the macro:

    Please Login or Register  to view this content.
    You can download the new zip file at: http://www.curtwatke.com/downloads/Desktop.zip
    ===============

    I am sorry I missed adding the word "Code" at the beginning of the code. Thanks too for adding that. However, adding the word "Code" doesn't actually answer the question. Any possibility of addressing the issue itself?

+ 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