sPath=oFileSys.GetSpecialFolder (iFolderConst) 或者: sPath=oFileSys.GetSpecialFolder (iFolderConst).Path 2.由于Path属性是Folder对象的缺省属性,所以第一个语句有效。因为不是给一个对象变量赋值,所以赋给sPath的值是缺省的Path属性值,...
Set objFolder = objFSO.GetFolder(ThisWorkbook.FullName) 'Get the folder object X Set objFolder = objFSO.GetFolder(ThisWorkbook.FullName).path X It is part of this code I am trying to adapt
'本代码不能再VB.net中运行,仅在VBA中运行OptionExplicitPrivateFSOXAsObject'特定路劲下的文件和文件夹列表PublicSubListFilesAndFolders()SetFSOX=CreateObject("Scripting.FileSystemObject")DimfolderPathAsStringIfSelectFolderPath(folderPath)=TrueThen' 替换为你的文件夹路径DimfolderAsObjectDimsubFolderAsObjectDimfileA...
Sub GetSubFolders() Dim fso As Object Dim folderPath As String Dim folderObject As Object Dim subFolderObject As Object folderPath = "C:\Users\Username\Documents\TestFolder" Set fso = CreateObject("Scripting.FileSystemObject") Set folderObject = fso.GetFolder(folderPath) For Each subFolderObject...
Dim objFolder As Object Set objshell = CreateObject("Shell.Application") '后期绑定Shell.Application '弹出对话框 Set objFolder = objshell.BrowseForFolder(0, "请选择文件夹", 0, 0) If Not objFolder Is Nothing Then Path = objFolder.Self.Path & "\" ...
Cells(LastRowB,2).Value=File.Path LastRowB=LastRowB+1 Next Nexti EndSub '''获取文件夹列表 SubFsoGetFolderList() DimrowIndexAsInteger DimfolderPathAsString '''调用函数获取主文件夹目录 folderPath=GetMainDirectory(msoFileDialogFolderPicker) rowIndex=1 Columns(1).Clear Do IfrowIndex=1Then Get...
' MsgBox "您选择的文件夹是:" & .SelectedItems(1) SelectGetFolder = .SelectedItems(1) Else SelectGetFolder = "" End If End With End Function '输入文件夹,返回数组=文件夹包含子文件夹列表 Function GetAllFolderPath(sPath As String) Dim aRes, sarr, sDic, sFso, F, Mat Dim FileName$, n...
Function ListFiles(ByVal folderPath As String, ByRef counter As Integer) '自定义函数-取得文件夹下的文件名,包括子文件夹 On Error GoTo ErrorHandler '出现错误处理 Dim fs As Object Set fs = CreateObject("Scripting.FileSystemObject") Dim folder As Object ...
Debug.Print fso.GetTempName '显示"radB0208.tmp",每次都会变。 12、BuildPath 方法 语法:object.BuildPath(path, name) 作用:追加一个名字到一个已经存在的路径。 示例: Debug.Print fso.BuildPath("c:\tmp", "abc") '显示"c:\tmp\abc" 13、CreateFolder 方法 语法:object.CreateFolder(foldername) 作用...
IsRootFolder属性判断文件夹是否为根文件夹,如果是则返回True,Boolean类型。 Name属性 返回文件夹的名称,String类型。 ParentFolder属性 返回指定文件夹的父文件夹。如果当前文件夹是它所在驱动器的根文件夹,则该属性无效。 Path属性 返回文件夹的完整路径...