Da thua anh, Vi sao khi in ra hinh anh lai ko hien duoc len vay anh? Em co 1 VBA nay nhung ko biet chay nhu the nao anh co the giai thich va chi giup em, sau khi cai dat VBA nay thi em nen dung cong thuc nao de chay duoc khong ah? Em cam on anh
Function LOT_PIC_PAC(LOT As String, DESTINATION_CELLS As Range, Optional PIC_BORDER As Boolean, Optional PIC_SHADOW As Boolean, Optional ENFORCE_SIZE As Boolean)
LOT_PIC_PAC = "Pic " & LOT
On Error GoTo SKIPIF
If DESTINATION_CELLS.Parent.Shapes(DESTINATION_CELLS.Address).AlternativeText = LOT Then Exit Function
DESTINATION_CELLS.Parent.Shapes(DESTINATION_CELLS.Address).Delete
SKIPIF:
Dim LFT As Double, TP As Double, WDTH As Double, HGT As Double, PIC As Object, i%
Dim FILEPATH(0 To 7) As String, PIC_NAME$
On Error GoTo 0
On Error GoTo EndIt
If LOT <> "0" Then
LFT = DESTINATION_CELLS.Left
TP = DESTINATION_CELLS.Top
WDTH = DESTINATION_CELLS.Width * 0.98
If DESTINATION_CELLS.Rows.Count > 1 Then WDTH = WorksheetFunction.Min(WDTH, DESTINATION_CELLS.Height / 1.41)
HGT = WDTH * 1.41
If ENFORCE_SIZE = True Then
WDTH = DESTINATION_CELLS.Width * 0.98
HGT = DESTINATION_CELLS.Height
End If
FILEPATH(0) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\ NoPicture.JPG"
If VBA.Environ("Username") = "Hoang Oanh" Then
FILEPATH(1) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
Else
FILEPATH(1) = "\\OANH-PC\ D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
End If
FILEPATH(2) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
FILEPATH(3) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
FILEPATH(4) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
FILEPATH(5) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
FILEPATH(6) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
FILEPATH(7) = "\\OANH-PC\D:\Oanh Vo\1a.Payless\13.Shipment\Tracking List\"
For i = 1 To UBound(FILEPATH, 1)
If VBA.IsNumeric(LOT) = True Then
PIC_NAME = Dir(FILEPATH(i) & Format(LOT, "000000") & "*")
Else
PIC_NAME = Dir(FILEPATH(i) & LOT & "*")
End If
If PIC_NAME <> "" Then
FILEPATH(0) = FILEPATH(i) & PIC_NAME
Exit For
End If
PIC_NAME = Dir(FILEPATH(i) & LOT & "*")
If PIC_NAME <> "" Then
FILEPATH(0) = FILEPATH(i) & PIC_NAME
Exit For
End If
If i = UBound(FILEPATH, 1) Then LOT_PIC_PAC = "Pic " & LOT & " not found"
Next i
On Error GoTo EndIt
If VBA.Right(FILEPATH(0), 4) = ".xls" Then GoTo EndIt
Set PIC = DESTINATION_CELLS.Parent.Shapes.AddPicture(FILEPATH(0), False, True, LFT, TP, WDTH, HGT)
PIC.Name = DESTINATION_CELLS.Address
PIC.AlternativeText = LOT
If PIC_BORDER = True Then PIC.DrawingObject.ShapeRange.Line.DashStyle = msoLineSolid
If PIC_SHADOW = True Then PIC.Shadow.Visible = True
End If
EndIt:
On Error GoTo 0
End Function