|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Dim Path0 As String
- Dim Path1 As String
- Dim d As Object
- Private Sub CommandButton1_Click()
- Unload Me
- End Sub
- Private Sub ListView1_DblClick()
- i = Me.ListView1.SelectedItem.Index
- If i < 0 Then Exit Sub Else s = Me.ListView1.ListItems(i).Text
- Debug.Print Path0
- Set Fso = CreateObject("scripting.filesystemobject")
- For Each fd In Fso.getfolder(Path1).subfolders
- If Len(Dir(fd.Path & "" & s, vbDirectory)) Then Shell "explorer.exe " & fd.Path & "" & s, vbNormalFocus
- Next
- End Sub
- Private Sub UserForm_Initialize()
- Path0 = ThisWorkbook.Path & "\档案目录.xls"
- Path1 = ThisWorkbook.Path & "\原文"
- Call GetData
- With Me.ListView1
- .ColumnHeaders.Add , , "档号", .Width / 3
- .ColumnHeaders.Add , , "题名", .Width * 2 / 3
- .View = lvwReport
- End With
- End Sub
- Private Sub 查询_Click()
- s = Me.TextBox1.Text
- Me.ListView1.ListItems.Clear
- For Each x In d.keys
- If InStr(x, s) Then
- i = i + 1
- Me.ListView1.ListItems.Add , , d(x)
- Me.ListView1.ListItems(i).SubItems(1) = x
- End If
- Next
- End Sub
- Private Sub GetData()
- Application.ScreenUpdating = False
- Set wb = Workbooks.Open(Path0)
- Set d = CreateObject("scripting.dictionary")
- With wb.Sheets(1)
- r = .UsedRange.Find("*", , -4163, 1, 1, 2).Row
- ar = .Range("A1:J" & r).Value
- For i = 2 To r
- If Len(ar(i, 10)) Then d(ar(i, 10)) = ar(i, 1)
- Next
- End With
- wb.Close False
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|