Home > fso getfolder error > fso.getfolder error

Fso.getfolder Error

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn vba getfolder path not found more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags

Filesystemobject Getfolder

Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBS can't find directory - 'Path Not Found' up vote 2 down vote favorite I have a script that obtains information about the current folders and subfolders within a specific directory. It works great, but I have stumbled across a strange issue: dim FSO, objFolder, datafolder, foldername, objSubfolder, totalSize dim objSubfolder2, objFolder2, mSize, size, today, dateLastMod foldername = "D:\folder\subfolder" set FSO = CreateObject("Scripting.FileSystemObject") set objFolder = FSO.GetFolder(foldername) set colSubfolders = objFolder.Subfolders today = Now ShowFolderDetails objFolder Function ShowFolderDetails(oF) datafolder = oF.Size/1073741824 wscript.echo oF.Name & " :Size= " & datafolder & " GB" wscript.echo oF.Name & " #Files= " & oF.Files.Count wscript.echo oF.Name & " #Folders= " & oF.Subfolders.count wscript.echo oF.Name & " Date Last Modified= " & oF.DateLastModified totalSize = totalSize + datafolder end Function And there is more to follow, but my issue is I get a path not found when I call that function. The folder is not located on the C:\ drive - which shouldn't be an issue. I have done this same script but changed foldername = D:\folder\differentsubfolder which works perfectly. But when I change it back to the other folder, it gives me a path not found error. I also tried putting everything below set FSO = CreatObject("Scripting.FileSytemObject") within an IF statement: IF FSO.FolderExists(foldername) Then .... This does enter in that IF statement, which makes me believe the VBS sees it, but I still get that error at line 17 (datafolder = oF.Size/1073741824). I have tried putting in the full folder path where the variable foldername is located (surrounded in quotes). I tried running my vbs pointed to other directories and it runs 100%. Its just that specific folder. There are no spaces in the folder name. Is there anything else I am missing? I have full admin access to the D:\ debugging vbscript permissions windows-server-2008-r2 filesystemobject share|improve this question edited Jan 26 '15 at 14:48 RubberDuck 5,67322458 asked Jun 13 '12 at 16:09 Zero Stack 212315 what happens if you rema

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/11019003/vbs-cant-find-directory-path-not-found up Using FileSystemObject to list files getting error up vote 2 down vote favorite I have Excel-2007. I am using File System Object VBA code to list files in a directory. I have also set up reference to Microsoft Scriptlet Library in excel. I am getting: Compiler error:User-defined type not defined on this very first code line Dim FSO As Scripting.FileSystemObject Code http://stackoverflow.com/questions/32359502/using-filesystemobject-to-list-files-getting-error used by me as follows: Sub ListFilesinFolder() Dim FSO As Scripting.FileSystemObject Dim SourceFolder As Scripting.Folder Dim FileItem As Scripting.File SourceFolderName = "C:\mydir" Set FSO = New Scripting.FileSystemObject Set SourceFolder = FSO.GetFolder(SourceFolderName) Range("A1:C1") = Array("text file", "path", "Date Last Modified") i = 2 For Each FileItem In SourceFolder.Files Cells(i, 1) = FileItem.Name Cells(i, 2) = FileItem Cells(i, 3) = FileItem.DateLastModified i = i + 1 Next FileItem Set FSO = Nothing End Sub Can someone point out where am I going wrong? **UPDATE -03-09-2015** I have updated my program based on @brettdj program and some research to list all files including sub-folder files. It works for me. I look forward to suggestions to further improve it. Sub ListFilesinFolder() Dim objFSO As Object Dim ws As Worksheet Dim cl As Range Dim objFolderName As String objFolderName = "C:\FY_2015-2016\sunil" Set objFSO = New Scripting.FileSystemObject Set ws = ActiveSheet With Range("A1:C1") .Value2 = Array("File", "path", "Date Last Modified") .Font.Bold = True End With Set cl = ws.Cells(2, 1) ListFolders cl, objFSO.GetFolder(objFolderName) Set objFSO = Nothing End Sub Sub ListFolders(rng As Range, Fol As Scripting.Folder) Dim SubFol As Scripting.Folder Dim FileIt

resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. https://msdn.microsoft.com/en-us/library/aa264506(v=vs.60).aspx The content you requested has been removed. You’ll be auto redirected in 1 second. Reference Trappable Errors Core Visual Basic Language Errors Core Visual Basic Language Errors 91 Object variable or With block variable not https://bytes.com/topic/asp-classic/answers/516963-object-required-error-using-filesystemobject set 91 Object variable or With block variable not set 91 Object variable or With block variable not set 3 Return without GoSub 5 Invalid procedure call or argument 6 Overflow 7 Out of fso.getfolder error memory 9 Subscript out of range 10 This array is fixed or temporarily locked 11 Division by zero 13 Type mismatch 14 Out of string space 16 Expression too complex 17 Can't perform requested operation 18 User interrupt occurred 20 Resume without error 28 Out of stack space 35 Sub, Function, or Property not defined 47 Too many DLL application clients 48 Error in loading DLL 49 Bad DLL calling vba getfolder path convention 51 Internal error 52 Bad file name or number 53 Can't find specified file 54 Bad file mode 55 File already open 57 Device I\O error 58 File already exists 59 Bad record length 61 Disk full 62 Input past end of file 63 Bad record number 67 Too many files 68 Device unavailable 70 Permission denied 71 Disk not ready 74 Can't rename with different drive 75 Path\File access error 76 Path not found 91 Object variable or With block variable not set 92 For loop not initialized 93 Invalid pattern string 94 Invalid use of Null 96 Can't sink this object's events because it's already firing events... 97 Can't call Friend procedure on an object that isn't an instance of... 98 A property or method call cannot include a reference to a private ... 321 Invalid file format 322 Can't create necessary temporary file 400 Form already displayed; can't show modally 422 Property not found 429 ActiveX component can't create object or return reference to this... 430 Class doesn't support Automation 432 File name or class name not found during Automation operation 438 Object doesn't support this property or method 440 Automation error 442 Connection to type library or object library for remot

Question Need help? Post your question and get tips & solutions from a community of 418,551 IT Pros & Developers. It's quick & easy. 'object required' error using FileSystemObject P: n/a google I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder ") Set fs = f.Files For Each fl in fs s = fl.Name 'Object Required error occurs here! Response.Write(s) Next Set fso = Nothing The asp page returns the 'Object Required' error on the line, "s = fl.Name". Why? Can anyone shed any light on this? Thanks Jul 28 '06 #1 Post Reply Share this Question 7 Replies P: n/a Janette For what it is worth, I have run this as both a stand alone vbscript and as an ASP page, and the only thing I changed was the path in the GetFolder command, and it worked fine for both. Both for a folder that did and didn't have contents. My only suggestions, are double check that you have the path correct and check that you have appropriate permissions to the folder. Also it might be worth running this script as a vbscript ie take the code, put it in a file called xxxx.vbs, change response.write(s) to msgbox s, save and run it by double clicking. This may help identify if it is a permissions problem. Hope this helps Janette I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder ") Set fs = f.Files For Each fl in fs s = fl.Name 'Object Required error occurs here! Response.Write(s) Next Set fso = Nothing The asp page returns the 'Object Requ

 

Related content

No related pages.