+ Reply to Thread
Results 1 to 7 of 7

400 error, picture insert, resize

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    400 error, picture insert, resize

    I'm trying to write a macro to insert a picture into a selected range and resize and center it while keeping the aspect ratio. it doesn't seem to work and i can't figure out why. it would insert the picture and size it to about a 1/4 of the range and leave it in the top left. I disable the error trap and it's giving me a 400 error with no debugging options. can anyone see what i'm doing wrong in my macro?. any help would be greatly appreciated.

    Chris


    Please Login or Register  to view this content.
    Last edited by Code Flunkie; 03-31-2010 at 02:27 PM.

  2. #2
    Registered User
    Join Date
    03-23-2010
    Location
    England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    27

    Re: 400 error, picture insert, resize

    Hi Chris

    I think this is what you want

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: 400 error, picture insert, resize

    wow works great, thanks a lot. just one more question

    is it possible to delete any picture already in the selected range first before putting the new picture in?

    Chris

  4. #4
    Registered User
    Join Date
    03-23-2010
    Location
    England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    27

    Re: 400 error, picture insert, resize

    Glad it helped Chris. I don't think there is a way to directly reference pictures within a range, although you could cycle through each shape within a worksheet, and determine whether any extents of a picture fall within the extents of the range, deleting as appropriate.
    Dave

  5. #5
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: 400 error, picture insert, resize

    Found a way to do it, and put some error handling incase no range is selected. but now i'm having the problem that if you cancel putting in the new picture the old picture is still deleted. any way around this that the the old picture is deleted only if a new picture is selected?

    Chris

    ps. posted the revised code below.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-23-2010
    Location
    England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    27

    Re: 400 error, picture insert, resize

    Well, before this thread I didn't know about IIf, Intersect, and the top left / bottom right cell references for shapes, so I'm doing well!

    Here's what you want, code tidied up and commented.

    Please Login or Register  to view this content.
    cheers
    Dave

  7. #7
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: 400 error, picture insert, resize

    Wow, that is exactly what i was looking for, well written too. thanks for taking the time to help me out and i'm glad you learned something too.

    Take care and thanks again

    Chris

+ 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