Questions tagged [fso]

Object Model component on Windows systems that represents the local file system.

The FileSystemObject (FSO) Object Model is used to access the local file system. Among other things, it provides methods for

  • reading file properties
  • creating and deleting files and folders
  • reading from files

For a complete list, visit the documentation link below.

Questions using the tag are expected to relate to programming

Links:

118 questions
2
votes
1 answer

Searching directory for files and listing their name and path - two levels of subfolders

Im currently trying to edit a previously created Macro by another team It very successfully is able to retrieve all file names and paths from a specific location, very useful if all the files are there. My issue is Im trying to adapt this to another…
Jacob Crux
  • 64
  • 2
  • 10
2
votes
1 answer

Two ways to write to text file using Excel VBA: Microsoft Standard Library vs Microsoft Scripting Runtime

I found there is two ways of creating and writing to a text file in Excel VBA: by using microsoft standard library or by using Microsoft Scripting Runtime. Are they equivalent? Below we have examples of both. Sub WriteToTextFile_FirstWay() Open…
sergio trajano
  • 189
  • 1
  • 1
  • 14
2
votes
1 answer

End loop after comparing filename and copying it in Vbscript

Im am trying to find files in a directory according to a list of numbers. Each file starts with the 6-digit- number but then can end with a random letters. - So i managed it to write a script which compares only the first six letters of the…
Marco
  • 328
  • 4
  • 14
2
votes
2 answers

FSO returns non-existing subfolders

I'm using this code to get the subfolders of a directory: Dim fo As Scripting.Folder Set fo = fso.GetFolder(m_sFolder) Dim nSubfolder As Scripting.Folder For Each nSubfolder In fo.SubFolders Debug.Print "Folder " & fo.Path & " has subfolder "…
tmighty
  • 10,734
  • 21
  • 104
  • 218
2
votes
3 answers

Saving a copy of an existing Excel workbook without overwriting it

I am trying to copy an Excel workbook from Folder X to Folder Y, and in the event that a file of that name already exists in Folder Y, the file is not overwritten but rather the new file is given a suffix of '- Copy', '- Copy (2)' etc - essentially…
finjo
  • 366
  • 4
  • 19
2
votes
1 answer

Undefined variable "file" in VBScript

I have this VBScript code that's supposed to write to every file in a directory: Option Explicit Dim fso: Set fso = CreateObject("Scripting.FileSystemObject") Dim dir: dir = fso.GetAbsolutePathName(".") & "/important/" For Each file In…
phriol
  • 101
  • 1
  • 1
  • 7
2
votes
1 answer

VBA Trim one Object with another Object in string (FSO.Getfolder related) Basically end up with relative path to a file

I am building this index of files in a directory. Column 1 with folder name(s), Column 2 with filename I have managed to get the actual filename and hyperlinking the filename already. But I have problems listing the path to the file in column 1,…
Doons
  • 183
  • 11
2
votes
0 answers

VBScript Folder.Size function on a very large folder not working

I'm trying to get the folder size of a folder that is over 2.5TB's large. I'm getting the following error - "The File or Directory is Corrupted and Unreadable", yet I can access the folder fine from windows. The folder is not located on my computer…
Khakis7
  • 413
  • 4
  • 19
2
votes
1 answer

Dir() and FSO Both Missing 1 File

All search attempts to find a solution to this issue have come up with the opposite of what I'm looking for. I do not need to exclude files from a search within a folder, but include them all. My issue is that my searches are returning all files…
Mike
  • 153
  • 1
  • 9
2
votes
1 answer

DeleteFolder method of FileSystemObject Does Not Give an Error (MSDN lied to me)

I have a couple folders on my desktop which I used temporarily for a macro. Now, I want to delete them. One is a .zip and one is a regular folder. Set fso = CreateObject("scripting.filesystemobject") fso.DeleteFolder unzipPath, True The above code…
ZX9
  • 898
  • 2
  • 16
  • 34
2
votes
4 answers

Why is this call to InvokeVerb ("&Print") not working?

I'm just trying to batch print a large amount of files from a folder. The folder contains multiple file types, and I just want to invoke the print method equivalent to Right-Click > Print. It seems like I should be able to do this using the…
CBRF23
  • 1,340
  • 1
  • 16
  • 44
2
votes
1 answer

VBScript read multiple filenames from txt file and list which do not exist in directory

I am new to VB scripting, and I was trying to find a way to: Read a list of file names written as lines of text inside a particular text file. Check if those files exist in the same directory as the script. Write the name of the files that do not…
user3242702
  • 21
  • 1
  • 3
2
votes
3 answers

Excel VBA - PDF file properties

first-time poster but long-time fan for finding VBA and SQL solutions on this site. I have a VBA subroutine that is designed to find all PDF files within a directory that the user designates. The program does recursions through all subfolders and…
Angler
  • 78
  • 1
  • 6
2
votes
2 answers

unzipping a file in classic asp

I'm trying to use an unzip/zip class. I need to unzip a zip file after upload. i modified "sleep" function to check "controller" function per intSeconds value and added "controller" function to check file count on target folder. You can see a code…
Salt Hareket
  • 764
  • 7
  • 18
1
vote
0 answers

VBA.Dir and FileSystemObject fail to correctly return Files.Count for a OneDrive folder

I have some automation code which recursively processes a folder structure in a local OneDrive for Business folder here: %UserProfile%\SPO_Domain\Site\Library There are hundreds of folders and thousands of files. In one folder this simple command…
Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24