|
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
With Application.FileDialog(msoFileDialogFolderPicker) '
If .Show Then myPath$ = .SelectedItems(1) Else Exit Sub '
End With '
If Right(myPath, 1) <> "" Then myPath = myPath & "" '
arr = ListAllFsoDic(myPath, 1)
Dim brr()
ReDim brr(1 To 10000, 1 To 3)
n = 1
brr(1, 1) = "序号"
brr(1, 2) = "工作簿名称"
brr(1, 3) = "文件路径"
For i = 0 To UBound(arr)
m = Dir(arr(i) & "\*.xls*") '
Do While m <> "" '
If m <> ThisWorkbook.Name Then '
n = n + 1
Set Itm = ListView1.ListItems.Add
Itm.Text = n - 1 '' ar(i, 1)
Itm.SubItems(1) = m
Itm.SubItems(2) = arr(i) & "\" & m
End If '
m = Dir '
Loop '
Next i
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
With ListView1
For i = 1 To .ListItems.Count Step 1
wj = .ListItems(i).SubItems(2)
Set wb = Workbooks.Open(wj)
wb.Worksheets("派工单").PrintOut
wb.Close False
Next i
End With
End Sub
Private Sub UserForm_Initialize()
rr = Array("序号", "工作簿名称", "文件路径")
For j = 0 To UBound(rr)
ListView1.ColumnHeaders.Add , , rr(j) ', Sheets("物料库存数据").Cells(3, j).Width
Next
ListView1.View = lvwReport
ListView1.FullRowSelect = True
ListView1.Gridlines = True
End Sub
|
|