top of page
About
About
FileSys is a VBA Module with methods and functions to read and manipulate files, and show file dialogs.
Download
Version history
Version history
v2.0.0 (Released on 2021-09-30)
- Added 'WriteBinFile' sub;
- Added 'ReadBinFile' function;
- Renamed 'WriteFile' sub to 'WriteTextFile';
- Renamed 'ReadFile' sub to 'ReadTextFile'.
v1.0.0 (Released on 2021-08-01)
- First public release.
Documentation
Documentation (v2.0.0)
Methods and functions
ReadTextFile
Declaration: ReadTextFile(Path As String, Optional Charset As String = "utf-8") As String
Description: Returns the contents of a file.
Parameters:
-
Path
-
Required
-
​Type: String
-
Description: Path of the file to read.
-
-
Charset
-
Optional
-
​Type: String
-
Description: File enconding (e.g. "utf-8", "ansi", etc.).
-
Example [VBA]
Dim FileContent As String
FileContent = ReadFile("C:\Users\User1\Documents\Example.txt")
WriteTextFile
Declaration: WriteTextFile Path As String, Content As String, Optional Charset As String = "utf-8"
Description: Changes the contents of a file or creates a new file.
Parameters:
-
Path
-
Required
-
​Type: String
-
Description: Path of the file to write.
-
-
Content
-
Required
-
​Type: String
-
Description: Content of the file to write.
-
-
Charset
-
Optional
-
​Type: String
-
Description: File enconding (e.g. "utf-8", "ansi", etc.).
-
Example [VBA]
WriteFile "C:\Users\User1\Documents\Example.txt", "Hello World!"
RenameFile
Declaration: RenameFile Path As String, NewPath As String
Description: Changes the path/name of a file.
Parameters:
-
Path
-
Required
-
​Type: String
-
Description: The current path of the file.
-
-
NewPath
-
Required
-
​Type: String
-
Description: The new path of the file.
-
Example [VBA]
' Renames the file from "Example.txt" to "Example test.txt" and moves it from "Documents" to "Desktop"
RenameFile "C:\Users\User1\Documents\Example.txt", "C:\Users\User1\Desktop\Example test.txt"
DeleteFile
Declaration: DeleteFile Path As String
Description: Deletes a file.
Parameters:
-
Path
-
Required
-
​Type: String
-
Description: Path of the file to delete.
-
Example [VBA]
DeleteFile "C:\Users\User1\Documents\Example.txt"
OpenFileDialog
Declaration: OpenFileDialog(FilterName As String, FilterExtensions As String, ButonName As String, Title As String, InitialFile As String) As String
Description: Shows a dialog box that lets the user choose a file. Returns the chosen file's path. If no file is chosen, then an empty string is returned.
Parameters:
-
FilterName
-
Required
-
​Type: String
-
Description: Name of the filter (e.g. "Images").
-
-
FilterExtensions
-
Required
-
​Type: String
-
Description: Extensions of the filter (e.g. "*.png; *.jpg; *.jpeg").
-
-
ButtonName
-
Required
-
​Type: String
-
Description: Name of the button.
-
-
Title
-
Required
-
​Type: String
-
Description: Title of the dialog box.
-
-
InitialFile
-
Required
-
​Type: String
-
Description: Path of the initial file or folder.
-
Example [VBA]
OpenFileDialog "Images", "*.png; *.jpg; *.jpeg", "Import", "Import image", "C:\Users\User1\Pictures\"
OpenFileDialog
Declaration: OpenFolderDialog(Title As String, InitialFile As String) As String
Description: Shows a dialog box that lets the user choose a folder. Returns the chosen folder's path. If no folder is chosen, then an empty string is returned.
Parameters:
-
Title
-
Required
-
​Type: String
-
Description: Title of the dialog box.
-
-
InitialFile
-
Required
-
​Type: String
-
Description: Path of the initial folder.
-
Example [VBA]
OpenFolderDialog "Choose project folder", "C:\Users\User1\"
bottom of page