Option Explicit
Private WithEvents cmbrs As CommandBars
Private Sub Workbook_Activate()
Set cmbrs = Application.CommandBars
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Set cmbrs = Application.CommandBars
End Sub
Private Sub cmbrs_OnUpdate()
Call ManipulateImage
End Sub
Private Sub ManipulateImage()
Dim shp As Shape
Dim AltTextCell As Range
Set shp = GetShape
If Not shp Is Nothing Then
On Error Resume Next
Set AltTextCell = Application.InputBox("Alt Text = " & shp.AlternativeText & vbLf & vbLf & "Select destination sheet and cell", Title:=shp.Name, Type:=8)
On Error GoTo 0
If Not AltTextCell Is Nothing Then
AltTextCell.Range("A1").Value = shp.AlternativeText
End If
End If
End Sub
Private Function GetShape() As Shape
Static oPreviousShp As Shape
Dim oCurrentShp As Shape
If TypeName(Selection) = "Picture" Then
Set oCurrentShp = Application.Selection.ShapeRange.Item(1)
If oPreviousShp Is oCurrentShp Then
Set GetShape = Nothing
Else
Set oPreviousShp = oCurrentShp
Set GetShape = oCurrentShp
End If
End If
End Function