Is this what you want?
Test in attached workbook
MoveAndResizeShapeWithoutRightClick.jpg
.
Only click events apply to shapes.
But here is a workaround using an active-x label:
- label is placed directly above the shape
- which allows label's MouseMove event to be used
- could be adapted to deal with many shapes
Const aShp = "myShape", aInf = "myInfo", aLbl = "myLabel"
Dim shp As Shape, lbl As Object, inf As Object, ShowInfo As Boolean
Dim L As Double, T As Double, W As Double, H As Double, TLC As String, BRC As String, myCaption As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Select Case ShowInfo
Case True: Call Update: Target.Activate: ShowInfo = False
Case Else: Me.OLEObjects("myInfo").Visible = False
End Select
End Sub
Private Sub myInfo_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Me.OLEObjects("myInfo").Visible = False
End Sub
Private Sub myLabel_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call Update
shp.Select
lbl.Height = 0: lbl.Width = 0 'temporary make label very small
End Sub
Sub Update()
Set shp = Me.Shapes(aShp)
Set lbl = Me.OLEObjects(aLbl)
Set inf = Me.OLEObjects(aInf)
Call ReAlign
inf.Visible = True
ShowInfo = True
End Sub
Private Sub ReAlign()
'shape details
With shp
L = .Left: T = .Top: H = .Height: W = .Width
TLC = .TopLeftCell.Address(0, 0): BRC = .BottomRightCell.Address(0, 0)
End With
'label position
With lbl
.Left = L: .Top = T: .Height = H: .Width = W
End With
'info position
With inf
.Left = L + W + 10: .Top = T
End With
'amend caption
myCaption = "Name = " & shp.Name & vbCr & "Cell Ref = " & TLC & vbCr & Format(H, "0.0") & " (h X w) " & Format(W, "0.0")
inf.Object.Caption = myCaption
End Sub
Bookmarks