Private Sub UserForm_Initialize() Dim tmp As Variant Dim filename As String Dim path As String path = ThisWorkbook.path & "\" & "需链接的目标文件" With Application.Filesearch .LookIn = path .SearchSubFolders = False .FileType = msoFileTypeExcelWorkbooks .NewSearch Debug.Print .Execute() If .Execute() > 0 Then For i = 1 To .FoundFiles.Count tmp = Split(.FoundFiles(i), "\") filename = Left(tmp(UBound(tmp)), Len(tmp(UBound(tmp))) - 4) ComboBox1.AddItem filename Next End If End With End Sub
复制到窗体里面即可... |