eiloken
Board Regular
- Joined
- Aug 11, 2023
- Messages
- 226
- Office Version
- 365
- 2016
- 2003 or older
- Platform
- Windows
Great day,
I create macro to insert picture to specific cell in each sheet in workbook, this macro will be call by parent macro which used to find specific cell in each sheet, but it seems problematic. In Sheet1 and some another sheets, it work corectly but some of them seems like set wrong "Top" property (please check attach screenshot), Can anyone help me with this problem? I preciate it.
I create macro to insert picture to specific cell in each sheet in workbook, this macro will be call by parent macro which used to find specific cell in each sheet, but it seems problematic. In Sheet1 and some another sheets, it work corectly but some of them seems like set wrong "Top" property (please check attach screenshot), Can anyone help me with this problem? I preciate it.
VBA Code:
Private Sub InsertStamp(ByVal dCll As Range, ByVal stampP As String)
Dim xSize As Double
Call CleanDestinationRange(dCll)
With dCll.MergeArea
If .Width > .Height Then 'looking for smaller property of cell and set it to picture size
xSize = .Height - 3
Else
xSize = .Width - 3
End If
'insert pictures and align it to center of width and height
.Worksheet.Shapes.AddPicture Filename:=stampP, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
Top:=.Top + (.Height - xSize) / 2, Left:=.Left + (.Width - xSize) / 2, Width:=xSize, Height:=xSize
End With
End Sub