BrendanDixon
Board Regular
- Joined
- Mar 7, 2010
- Messages
- 174
- Office Version
- 365
- 2019
- Platform
- Windows
Hi All,
I have a document where a buyer wants to insert his signature automatically. The code for installing the signature works fine. The problem is that when I run the code to remove the signature it removes all the signaures except for the signature in Cell A84. All the cells are identical so I cannot work out what is going on. I hope somone can help me work this out. I have spent 2 days on this problem without a solution so far.
I have a document where a buyer wants to insert his signature automatically. The code for installing the signature works fine. The problem is that when I run the code to remove the signature it removes all the signaures except for the signature in Cell A84. All the cells are identical so I cannot work out what is going on. I hope somone can help me work this out. I have spent 2 days on this problem without a solution so far.
VBA Code:
Sub Insert()
Dim photoNameAndPath As Variant
Dim photo As Picture
photoNameAndPath = Application.GetOpenFilename(Title:="Select Photo to Insert")
If photoNameAndPath = False Then Exit Sub
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("A1").Left
.Top = ActiveSheet.Range("A1").Top
.Width = ActiveSheet.Range("A1:C3").Width
.Height = ActiveSheet.Range("A1:C3").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("B10").Left
.Top = ActiveSheet.Range("B10").Top
.Width = ActiveSheet.Range("B10:C11").Width
.Height = ActiveSheet.Range("B10:C11").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("C20").Left
.Top = ActiveSheet.Range("C20").Top
.Width = ActiveSheet.Range("C20:D21").Width
.Height = ActiveSheet.Range("C20:D21").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("D30").Left
.Top = ActiveSheet.Range("D30").Top
.Width = ActiveSheet.Range("D30:E31").Width
.Height = ActiveSheet.Range("D30:E31").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("E40").Left
.Top = ActiveSheet.Range("E40").Top
.Width = ActiveSheet.Range("E40:F41").Width
.Height = ActiveSheet.Range("E40:F41").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("A84").Left
.Top = ActiveSheet.Range("A84").Top
.Width = ActiveSheet.Range("A84:B85").Width
.Height = ActiveSheet.Range("A84:B85").Height
.Placement = 1
End With
Set photo = ActiveSheet.Pictures.Insert(photoNameAndPath)
With photo
.Left = ActiveSheet.Range("C215").Left
.Top = ActiveSheet.Range("C215").Top
.Width = ActiveSheet.Range("C215:E216").Width
.Height = ActiveSheet.Range("C215:E216").Height
.Placement = 1
End With
End Sub
VBA Code:
Sub remove()
Dim s As Shape, rng As Range
Set rng = Range("A1:A1")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("B10:B10")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("C20:C20")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("D30:D30")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("E40:E40")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("A84:A84")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Set rng = Range("C215:C215")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
End Sub