xlr8urknowledge
New Member
- Joined
- Dec 7, 2012
- Messages
- 11
Hi all,
VBA dabbler here! I wrote this code to track training records and update actual signatures. The portion I am having difficulty with is I want to replace a signature shape (captured signature bitmap image) and not just add it over the previous one. to delete the shape I have it locating the cell that holds the shape in it by row and column. The column doesn't change but the row will. I wanted the column option in case I added more columns. I've stepped through the VBA code several times and for some reason when I install a copied sheet from a template sheet, the code will not complete and errors as it searches shapes on the sheet but when the loop criteria is met is does not delete the shape.
There may be a much better way to do this, but I don't know why it does not follow the directions I gave it. Non logical driving me nuts!!
Questions:
Thanks for any and all help!!
Happy 4th of July USA!
Ken
Red code is where error happens and goes to handler after looping past.
VBA dabbler here! I wrote this code to track training records and update actual signatures. The portion I am having difficulty with is I want to replace a signature shape (captured signature bitmap image) and not just add it over the previous one. to delete the shape I have it locating the cell that holds the shape in it by row and column. The column doesn't change but the row will. I wanted the column option in case I added more columns. I've stepped through the VBA code several times and for some reason when I install a copied sheet from a template sheet, the code will not complete and errors as it searches shapes on the sheet but when the loop criteria is met is does not delete the shape.
There may be a much better way to do this, but I don't know why it does not follow the directions I gave it. Non logical driving me nuts!!
Questions:
- Is there an easier way to achieve the replacement of the shape rather than adding one on top of the other?
- could I make the column fixed at 9 (see code example) and then just loop rows for 9 (see code example)?
- what is the criteria VBA uses to decide what row and column to loop through? (I see it go to column 12 where the macro buttons are and then search all of the active rows then it goes to column 9 where the signatures are and loops through past row 9 then errors!???)
Thanks for any and all help!!
Happy 4th of July USA!
Ken
Rich (BB code):
Sub SignatureQSM()
Dim ActSheet As Worksheet
Dim ActSheetName As String
Dim Sh As Shape
Dim pword As String
Dim ADate As String
On Error GoTo handler
pword = Application.InputBox("Enter password", "Sign for Completed Training", Type:=2)
If pword <> "xx" Then Exit Sub
Set ActSheet = Sheets(ActiveSheet.Name)
ActSheetName = ActiveSheet.Name
Set ActSheet = Nothing
ActiveWorkbook.Unprotect Password:="xyz"
ActiveSheet.Unprotect Password:="zyx"
For Each Sh In ActiveSheet.Shapes
If Sh.TopLeftCell.Row = 9 And Sh.TopLeftCell.Column = 9 Then Sh.Delete
Next Sh
Red code is where error happens and goes to handler after looping past.