I have peiced together the following macro to insert a signature on the timesheet. It is working but not without issue.
Sub SignDocument()
On Error GoTo errh
Dim myPath As Variant
Dim lngLeft As Long
Dim lngTop As Long
Dim shpPic As Shape
If ActiveSheet.Pictures.Count > 0 Then
rsp = MsgBox("This Timesheet is already signed" & vbCr _
& "Delete existing signature and re-sign?", vbYesNo)
If rsp = vbNo Then Exit Sub
If rsp = vbYes Then
ActiveSheet.Pictures(1).Delete
End If
End If
Range("A63:U66").Select
myPath = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif; *.png), *.gif; *.jpg; *.bmp; *.tif; *.png", _
, "Select Picture to Import")
lngLeft = Columns("B").Left + 5
lngTop = Rows(62).Top + 5
Set shpPic = ActiveSheet.Shapes.AddPicture(myPath, False, True, lngLeft, lngTop, -1, -1)
With shpPic
.Width = 200
.Locked = True
MsgBox ("Processing.... " & vbCr _
& "You may need to re-position and resize your signature to fit the signature line")
shpPic.Select
End With
Exit Sub
errh:
MsgBox "Signature Canceled"
End Sub
The code functions perfect......as long as my ActiveX Toggle Button (ToggleButton1) is not there. It sees it as a shape and wants to delete it. How can this code be written as to either skip ToggleButton1 or only delete actual pictures? I have the sheet attached to aid in helping with a solution. Many thanks!
Timesheet Editing test.xlsm
Bookmarks