Chào các bác,
em đang làm một đoạn code chèn hình tự động từ folder có sẵn vào file excel , Như file đính kèm và code như bên dưới.
Em cũng chỉ mới tự học và mày mò trên internet.
Các anh chị giúp em xem đoạn code e viết sai gì sao mà 3 ngày nay em nghiên cứu cũng ko biết mình sai gì mà không ra.
Cám ơn cả nhà.
Private Sub Insert_photo(ByVal target As Range)
'
' Insert_photo Macro
' find and insert photo
'
'
Dim sh As Object
target.Select
ActiveCell = target
sh.TopLeftCell.Address = target(1, 0).Address
If target <> "" Then ActiveSheet.Picture.Insert("D:\Thanh - Data\Thu thuat Excel\Insert photo to excel\" & target.Value & ".jpg").Select
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Height = target.Offset(1, 0).Height
.Width = target.Offset(1, 0).Width
End With
ActiveWorkbook.Save
End Sub
em đang làm một đoạn code chèn hình tự động từ folder có sẵn vào file excel , Như file đính kèm và code như bên dưới.
Em cũng chỉ mới tự học và mày mò trên internet.
Các anh chị giúp em xem đoạn code e viết sai gì sao mà 3 ngày nay em nghiên cứu cũng ko biết mình sai gì mà không ra.
Cám ơn cả nhà.
Private Sub Insert_photo(ByVal target As Range)
'
' Insert_photo Macro
' find and insert photo
'
'
Dim sh As Object
target.Select
ActiveCell = target
sh.TopLeftCell.Address = target(1, 0).Address
If target <> "" Then ActiveSheet.Picture.Insert("D:\Thanh - Data\Thu thuat Excel\Insert photo to excel\" & target.Value & ".jpg").Select
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Height = target.Offset(1, 0).Height
.Width = target.Offset(1, 0).Width
End With
ActiveWorkbook.Save
End Sub