Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

How to make shapes unselectable?

$
0
0

Im making a small excel add-in to mark selected row and column using rectangles. Is there any way to make them unselectable? Should i use something else?

A piece of the code that goes in ThisWorkbook of the add-in:

Private ROW_SHAPE As Shape
Private COLUMN_SHAPE As Shape
Private Sub AddShapes(ByVal Sh As Object)
    VisibleRangeHeight = ActiveWindow.ActivePane.VisibleRange.Height
    VisibleRangeWidth = ActiveWindow.ActivePane.VisibleRange.Width
    SelectedCellHeight = Selection.Height
    SelectedCellWidth = Selection.Width
    If SelectedCellHeight > VisibleRangeHeight Then
        SelectedCellHeight = VisibleRangeHeight
    End If
    If SelectedCellWidth > VisibleRangeWidth Then
        SelectedCellWidth = VisibleRangeWidth
    End If
    CellPosLeft = Selection.Left
    CellPosTop = Selection.Top
    Set ROW_SHAPE = Sh.Shapes.AddShape(msoShapeRectangle, 1, CellPosTop, _
        VisibleRangeWidth + CellPosLeft, SelectedCellHeight)
    With ROW_SHAPE
        .Name = "row_shape"
        .Line.ForeColor.RGB = RGB(255, 0, 0)
        .Fill.Visible = msoFalse
        With .Shadow
           .Visible = True
           .Blur = 4
           .OffsetX = 1
           .OffsetY = 1
           .ForeColor.RGB = RGB(255, 0, 0)
        End With
    End With
    Set COLUMN_SHAPE = Sh.Shapes.AddShape(msoShapeRectangle, CellPosLeft, 1, _
        SelectedCellWidth, VisibleRangeHeight + CellPosTop)
    With COLUMN_SHAPE
        .Name = "column_shape"
        .Line.ForeColor.RGB = RGB(255, 0, 0)
        .Fill.Visible = msoFalse
        With .Shadow
           .Visible = True
           .Blur = 4
           .OffsetX = 1
           .OffsetY = 1
           .ForeColor.RGB = RGB(255, 0, 0)
        End With
    End With
End Sub

Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>