none
Add border on shap selection RRS feed

  • Question

  • I want to select a image and then run a function that add border around that selection. Problem is, if I have two pictures on the worksheet that is "Picture 1" in the name box, selecting the second picture beneath the first one then running function to add the border will result in adding the border to the first picture since they are both called "Picture 1". Any workaround this issue?

    Private Function AddImageBorder(WhichSheet As String)
    
        With ActiveWorkbook.Sheets(WhichSheet).Shapes(Selection.Name)
            .Line.Weight = 5
            .Line.Visible = msoTrue
        End With
        
    End Function





    • Edited by vkid12 Wednesday, April 13, 2016 7:02 PM
    Wednesday, April 13, 2016 7:02 PM

All replies

  • It is not a good practice to have two shapes with the same name in a worksheet. Why would you do that?

    About your question, here is a suggestion:

        With Selection
            .Line.Weight = 5
            .Line.Visible = msoTrue
        End With


    http://www.ambienteoffice.com.br - http://www.clarian.com.br

    Wednesday, April 13, 2016 10:19 PM
  • Hi vkid12,

    Could you specify a selected image?  i.e. which image is selected. 
    If you could, 
      1) get the name of shape (the selected image)
      2) add border to the shape

    Regards.
    Friday, April 15, 2016 12:51 AM