Hi Marrick,
It's not clear where your two procedures fit into the overall scheme of things. The first one, with '.AllowMultiSelect = True', suggests it's used to identify the files to be updated. If so, I think the following will work better:
Code:
Private Sub CmdTarget_Click()
Dim TargetFile As Variant, i As Long
'Create a FileDialog object as a File Picker dialog box.
With Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "All Word Documents", "*.doc; *.dot; *.rtf; *.docx; *.docm; *.dotx; *.dotm", 1
.AllowMultiSelect = True
If .Show = -1 Then
' User clicked OK
With ListBox3
.ColumnCount = 2
.ColumnWidths = "0; 60"
End With
' Populate the listbox
For Each TargetFile In .SelectedItems
ListBox3.AddItem (TargetFile)
ListBox3.Column(1, i) = Split(TargetFile, "\")(UBound(Split(TargetFile, "\"))) 'gets the filename
i = i + 1
Next
' Report the file count
lblTargetCount.Caption = "(" & .SelectedItems.Count & ")"
Else
' User clicked Cancel
Exit Sub
End If
End With
End Sub
To loop through the listbox, you could use code like:
Code:
Sub Demo()
Dim i As Long
With ListBox3
For i = 0 To .ListCount - 1
MsgBox .Column(0, i)
Next
End With
End Sub
PS: When posting code, please use code tags.