ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Picture during Double Click (https://www.excelbanter.com/excel-discussion-misc-queries/52349-picture-during-double-click.html)

aftamath

Picture during Double Click
 
I'm trying to get the code in VBA to insert and remove a picture from a cell
when double clicked. Is this possible and how do I get the picture to center
in the cell.

Please fix this code.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True

If Target.Column = 8 Then
If Trim(Target.Value) = "" Then
Target.Value = Pictures.Insert("A:\Check.gif")
Target.PicturePosition = fmPicturePositionCenter
ElseIf Target.Value = ActiveSheet.Pictures.Insert("A:\Check.gif") Then
Target.Value = ActiveSheet.Pictures.Delete("A:\Check.gif")
Else
MsgBox "Cannot toggle switch in " & Target.Address(0, 0)
End If
End If



End Sub


All times are GMT +1. The time now is 11:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com