Public Sub InsertPictureToColumn(Sh As Object, RngPicture As Range, PreName$, NextPictureTop!, PictureFullName$, _
Optional StrHyperLink$, Optional StrScreenTip$, Optional CountPictures&, Optional kZoom!, Optional FlagCenter As Boolean)
On Error Resume Next
Application.ScreenUpdating = False
Dim MyPicture As Object, PicName$
If kZoom <= 0 Then kZoom = 100
Sh.Unprotect
With Sh.Pictures.Insert(PictureFullName)
.Name = PreName & Format(CountPictures, "00")
.Top = NextPictureTop + 0.75
.Left = RngPicture.Left + 0.75
.Width = kZoom / 100 * RngPicture.Width - 0.75
If FlagCenter Then
If .Height > RngPicture.Height Then
.Height = RngPicture.Height
ElseIf .Height < RngPicture.Height Then
.Top = RngPicture.Top + (RngPicture.Height - .Height) / 2
End If
.Left = RngPicture.Left + (RngPicture.Width - .Width) / 2
End If
NextPictureTop = NextPictureTop + .Height + 0.75
If StrHyperLink <> vbNullString Then
Sh.Hyperlinks.Add Anchor:=Sh.Shapes(.Name), Address:=StrHyperLink, ScreenTip:=StrScreenTip
End If
End With
End Sub
Public Sub InsertPictureToRow(Sh As Object, RngPicture As Range, PreName$, NextPictureLeft!, PictureFullName$, _
Optional StrHyperLink$, Optional StrScreenTip$, Optional CountPictures&, Optional kZoom!, Optional FlagCenter As Boolean)
On Error Resume Next
Application.ScreenUpdating = False
Dim MyPicture As Object, PicName$
If kZoom <= 0 Then kZoom = 100
Sh.Unprotect
With Sh.Pictures.Insert(PictureFullName)
.Name = PreName & Format(CountPictures, "00")
.Left = NextPictureLeft + 0.75
.Top = RngPicture.Top + 0.75
.Height = kZoom / 100 * RngPicture.Height - 0.75
If FlagCenter Then
If .Width > RngPicture.Width Then
.Width = RngPicture.Width
.Top = RngPicture.Top + (RngPicture.Height - .Height) / 2
ElseIf .Width < RngPicture.Width Then
.Height = RngPicture.Height
.Left = RngPicture.Left + (RngPicture.Width - .Width) / 2
End If
End If
NextPictureLeft = NextPictureLeft + .Width + 0.75
If StrHyperLink <> vbNullString Then
Sh.Hyperlinks.Add Anchor:=Sh.Shapes(.Name), Address:=StrHyperLink, ScreenTip:=StrScreenTip
End If
End With
End Sub