Set sFolder = iFolder.SubFolders Set iFile = iFolder.Files With ActiveSheet For Each gFile In iFile ' .Hyperlinks.Add anchor:=.Cells(iCount, 1), Address:=gFile.path, TextToDisplay:=gFile.Name iCount = iCount + 1
PublicSubtest()DimstrPathAsStringDimfsoAsObjectDimobjFolderAsObjectSetfso=CreateObject("Scripting.FileSystemObject")lngSeqNo=0strPath="C:\Users\Administrator\Documents\Tencent Files\13685293"SetobjFolder=fso.GetFolder(strPath)GetAllFiles objFolder' ReDim Preserve arrFiles(1 To lngFileCnt)' For i = ...
Set fso=CreateObject("Scripting.FileSystemObject")Set fld=fso.GetFolder(folderPath)' 调用递归函数获取最新日期 CallLookUpAllFiles(fld,latestDate)' 输出最新日期 GetLatestModifiedDate2=latestDate End Function SubLookUpAllFiles(fld As Variant,ByRef latestDate As Date)'递归,获取文件的最新修改日期 Dim objF...
'''获得mainFolder的子目录集合childFolders SetchildFolders=mainFolder.SubFolders '''行号初始值设定为A列最后一个非空行的+1行,第一次执行的时候index=2 index=Cells(Rows.Count,1).End(xlUp).Row+1 '''for each ……in遍历集合取每一个子目录childFolder的路径path ForEachchildfolderInchildFolders Cells...
SubLookupAllFiles(fld As Folder)Dim fil As File,outFld As Folder For Each fil In fld.Files Debug.Print fil.Name Next For Each outFld In fld.SubFolders LookupAllFiles outFld '递归法,调用自身 Next End Sub 运行getAllFileNames的代码,立即窗口中显示的是: ...
False Application.DisplayAlerts = False ' Loop through each Excel file in the folder ...
Cells(i,1) =f.ParentFolder.path i= i +1EndIfNextForEachfdInFld.SubFolders Cells(i,1) =fd.path i= i +1CallListAllFso(fd.path, i)NextEnd Function 上面,根据使用略微调整 SubListFilesTest()'With Application.FileDialog(msoFileDialogFolderPicker)'If .Show Then myPath$ = .SelectedItems(1) ...
() Dim varFName As Variant Dim fn As Variant 'Excel档由Excel开,其它文档由ShellExecute函数开 varFName = Application.GetOpenFilename(, , "开启文档", MultiSelect:=True) If IsArray(varFName) Then For Each fn In varFName If LCase(Right(fn, 3)) "xls" Then ShellExecute 0, "open", ...
oTempFolder In oSubFolders sTempPath = oTemp.Path Call EnuAllFilessTempPath, True) Next End If SetoSubFolders = Nothing End If Set oFile = Nothing Set oFolder =Nothing Set oFso = Nothing Sub Function GetPath() As String '声明个FileDialog变量 Dim oFD FileDialog ' '创建...
output folder or work folder, then it may lead to the situation in which the VbaCompiler is unable to create a DLL file in the currently set output folder. We recommend that you set youroutput folderandwork folderinside of your account’s “My Documents” folder or any of its subfolders....