LibreOffice 25.2 Help
āĻĄā§āϰāĻžāĻāĻ āĻ āĻĨāĻŦāĻž āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋāϰ āĻāϞā§āϞā§āĻāĻŋāϤ āĻ āύā§āϏāύā§āϧāĻžāύ āĻĒāĻžāĻĨā§āϰ āϏāĻžāĻĨā§ āĻŽāĻŋāϞ⧠āϝāĻžā§ āĻāĻŽāύ āĻāĻāĻāĻŋ āĻĢāĻžāĻāϞ, āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋ āĻ āĻĨāĻŦāĻž āϏāĻāϞ āĻĢāĻžāĻāϞ āĻāĻŦāĻ āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋ āĻĒā§āϰāĻĻāĻžāύ āĻāϰ⧠āĻĨāĻžāĻā§āĨ¤
Dir [(PathName As String [, Attributes As Integer])]
āϏā§āĻā§āϰāĻŋāĻ
PathName: Any string expression that specifies the search path, directory or file. This argument can only be specified the first time that you call the Dir function. If you want, you can enter the path in URL notation.
Attributes:Any integer expression that specifies bitwise file attributes. The Dir function only returns files or directories that match the specified attributes. You can combine several attributes by adding the attribute values:
0 : āϏā§āĻŦāĻžāĻāĻžāĻŦāĻŋāĻ āĻĢāĻžāĻāϞāĨ¤
16 : āĻļā§āϧā§āĻŽāĻžāϤā§āϰ āĻĄāĻŋāϰā§āĻā§āĻāϰā§āϰ āύāĻžāĻŽ āĻĢā§āϰāϤ āĻĒāĻžāĻ āĻžā§āĨ¤
āĻĢāĻžāĻāϞ āĻ āĻĨāĻŦāĻž āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋ āĻāĻĒāϏā§āĻĨāĻŋāϤ āĻāĻā§ āĻāĻŋāύāĻž āϤāĻž āĻĒāϰā§āĻā§āώāĻž āĻāϰāĻžāϰ āĻāύā§āϝ āĻ āĻĨāĻŦāĻž āĻāĻāĻāĻŋ āĻāϞā§āϞā§āĻāĻŋāϤ āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋāϤ⧠āϏāĻāϞ āĻĢāĻžāĻāϞ āĻāĻŦāĻ āĻĢā§āϞā§āĻĄāĻžāϰ āύāĻŋāϰā§āϧāĻžāϰāĻŖ āĻāϰāĻžāϰ āĻāύā§āϝ āĻāĻ āĻŦā§āĻļāĻŋāώā§āĻā§āϝāĻžāĻŦāϞ⧠āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻāϰā§āύāĨ¤
āĻĢāĻžāĻāϞ āĻāĻĒāϏā§āĻĨāĻŋāϤ āĻāĻāĻŋ āĻāĻŋāύāĻž āϤāĻž āĻĒāϰā§āĻā§āώāĻž āĻāϰāĻžāϰ āĻāύā§āϝ āĻĢāĻžāĻāϞā§āϰ āϏāĻŽā§āĻĒā§āϰā§āĻŖ āĻĒāĻžāĻĨ āĻāĻŦāĻ āύāĻžāĻŽ āϏāύā§āύāĻŋāĻŦā§āĻļ āĻāϰāĻžāύāĨ¤ āϝāĻĻāĻŋ āĻĢāĻžāĻāϞ āĻ āĻĨāĻŦāĻž āĻĄāĻŋāϰā§āĻā§āĻāϰāĻŋāϰ āύāĻžāĻŽ āĻŦāĻŋāĻĻā§āϝāĻŽāĻžāύ āύāĻž āĻĨāĻžāĻā§ āϤāĻžāĻšāϞ⧠Dir āĻĢāĻžāĻāĻļāύāĻāĻŋ āĻāĻāĻāĻŋ āĻļā§āύā§āϝ āĻĻā§āϰā§āĻā§āϝā§āϰ āϏā§āĻā§āϰāĻŋāĻ("") āĻĒā§āϰāĻĻāĻžāύ āĻāϰ⧠āĻĨāĻžāĻā§āĨ¤
To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.ods". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments.
To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition).
Sub ExampleDir
REM āĻ āϏāĻāϞ āĻĢāĻžāĻāϞ āĻāĻŦāĻ āĻĄāĻŋāϰā§āĻā§āĻāϰ⧠āĻĒā§āϰāĻĻāϰā§āĻļāĻŋāϤ āĻšā§
Dim sPath As String
Dim sDir As String, sValue As String
sDir="Directories:"
sPath = CurDir
sValue = Dir$(sPath + getPathSeparator + "*",16)
Do
If sValue <> "." And sValue <> ".." Then
If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then
REM get the directories
sDir = sDir & chr(13) & sValue
End If
End If
sValue = Dir$
Loop Until sValue = ""
MsgBox sDir,0,sPath
End Sub