+ Reply to Thread
Results 1 to 5 of 5

Use a button to control a macro that inserts an image into a shape or resets the shape

  1. #1
    Registered User
    Join Date
    03-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    45

    Use a button to control a macro that inserts an image into a shape or resets the shape

    I have a worksheet with 4 rectagles that I created using the drawing tool. I am trying to write a macro that will allow me to use 2 buttons, one to insert a image into the predefined shape and another button to reset the shape back to the original default. In the attached workbook, I have a macro that kind of does what i want however, I do not like that if I cancel the "insert image" it dislays the error link to this post. If it is easier, i would be happy if the image was inserted in a box of merged cells as well.....either way accoplishes the task.

    error.png

    I am using the following macro:

    Please Login or Register  to view this content.
    But... I like how this one works: (thanks Steve...aka Nevets)

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by nwb; 05-10-2013 at 01:15 PM. Reason: forgot to wrap code

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Use a button to control a macro that inserts an image into a shape or resets the shape

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    You just need to include the line

    Please Login or Register  to view this content.
    which will exit the routine if the dialog was cancelled.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Use a button to control a macro that inserts an image into a shape or resets the shape

    Andy,

    Sorry for my failure to comply with the forum rules. This is only my second post, and I very new to VBA. Thank you for the solution to one of the bigger issues with my code. I have been instructed to make adjustments on how our staff would like the images to be handled (see "Report Revised" attachment)

    Report Revised.xlsm

    Basically, they want to eliminate the step where one would have to click on the shape and just have a set of buttons for each picture, one to insert and one to reset the image. I have 4 rectangles could I assign CommandButton1 to insert image in Rectangle 1 and CommandButton2 to reset the image to its original format, duplicated this to the remaining 3 rectangles?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Use a button to control a macro that inserts an image into a shape or resets the shape

    Here is the code for first set of buttons

    Please Login or Register  to view this content.
    Add same code to other insert/reset buttons changing name of shape holding the image.

    code in standard module to fill/reset shapes content.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Use a button to control a macro that inserts an image into a shape or resets the shape

    I am truley amazed at the broad knoweldge of the members of this forum. I hope one day to be able to pay it forward. Where would I turn to learn basic VBA terms and entry level clarification?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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