Function GetListViewValue(ByRef oLV As ListView, ByVal lRow As Long, lCol As Long, Optional sEmptyValue As String = vbNullString, Optional ByVal sMissingCell As String = "#ERROR#") As String
' oLV : la ListView
' lRow : numéro de ligne. commence 0 = header
' lCol : numéro de colonne. commence à 1
' sEmptyValue : valeur à retourner en cas de cellule vide
' sMissingCell : valeur à retourner en cas d'erreur (cellule n'existe pas)
GetListViewValue = sMissingCell
With oLV
If (lRow >= 0) And (lCol >= 1) Then
If (lRow <= .ListItems.Count) And (lCol <= .ColumnHeaders.Count) Then
If lRow = 0 Then 'header
GetListViewValue = IIf(LenB(.ColumnHeaders(lCol).Text) = 0, sEmptyValue, .ColumnHeaders(lCol).Text)
ElseIf lCol = 1 Then '1ère colonne
GetListViewValue = IIf(LenB(.ListItems(lRow).Text) = 0, sEmptyValue, .ListItems(lRow).Text)
Else 'les autres colonnes
GetListViewValue = IIf(LenB(.ListItems(lRow).SubItems(lCol - 1)) = 0, sEmptyValue, .ListItems(lRow).SubItems(lCol - 1))
End If
End If
End If
End With
End Function