Consulting

Results 1 to 2 of 2

Thread: Bring picture to front

  1. #1

    Bring picture to front

    I have a VBA code I have inserted so that when I click on the cell an image is located, the image is enlarged (250x250), and when I click on the cell to the left of the cell the image is located, it's size is reduced (80x80). However, I would like to add a command that when the image is enlarged, it is BROUGHT FORWARD of the all the other images.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    'UpdatebyEntendoffice20161111
    Application.ScreenUpdating = False
    Dim xRg As Range, sPic As Shape
    For Each sPic In ActiveSheet.Shapes
    If Target.Column > 5 Then
    Set xRg = Target.Offset(, 0)
    With sPic
    If TypeName(.OLEFormat.Object) = "Picture" Then
    If .TopLeftCell.Address = xRg.Address Then
    .Height = 350
    .Width = 350
    End If
    End If
    End With
    ElseIf Target.Column = 5 Then
    With sPic
    If TypeName(.OLEFormat.Object) = "Picture" Then
    .Height = 80
    .Width = 80
    End If
    End With
    End If
    Next sPic
    Application.ScreenUpdating = True
    End Sub

    bring to front.jpg

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    Add .ZOrder msoBringToFront
    to:
              .Height = 350
              .Width = 350
              .ZOrder msoBringToFront 'add
    Maybe do the same further down in the code too, but it may not be needed.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •