Chdir functions
The Microsoft Excel CHDIR statement allows you to change the current
directory or folder.
Syntax
Chdir path
Example
Chdir”c:/docments”
In this example, the
current directory would now be changed to C:\instructions.
chdrive
The Microsoft Excel CHDRIVE statement allows you to change the current
drive.
Syntax
Chdrive drive
Example
Chdrive”c”
Chdir”c:/docments
In this example, the
current drive is set to the S drive. Then the current directory is set to
S:\Games.”
Curdir function
The Microsoft Excel CURDIR function returns the current path.
Syntax
Curdir(drive)
Example
Dim lresult as string
Lresult = curdir()
Dir function
The Microsoft Excel DIR function returns the first filename that matches
the pathname and attributes specified. To
retrieve additional filenames that match pathname and attributes, call DIR again
with no arguments.
Syntax
Dir(path)
Example
Dim lresult as string
Lresult =dir(“c:/janus.doc”)
In this example, the
variable called LResult would now contain the filename of the janus.doc
file.
File date and time
function
The Microsoft Excel FILEDATETIME function returns the date and time of
when a file was created or last modified.
Syntax
Filedatetime(file path)
Example
Dim lresult as string
Lresult =filedatetime(“c:/janus.doc”)
In this example, the
variable called LResult would now contain the create or last modified date for
the c:/janus.doc file.
File length function
The Microsoft Excel FILELEN function returns the size of a file in bytes.
Syntax
Filelen(file _path)
Example
Dim lresult as string
Lresult =filelen(“c:/janus.doc”)
In this example, the
variable called LResult would now contain the size of the c:/janus.doc
file in bytes.
Getattr function
The Microsoft Excel GETATTR function returns an integer that represents
the attributes of a file, folder, or directory.
Syntax
Getattr(path)
Example
Dim lresult as string
Lresult =getattr(“c:/janus.doc”)
In this example, the
variable called LResult would now contain the integer representation of the
attributes of the janus.doc file.
Setattr function
The Microsoft Excel SETATTR statement
allows you to set the attributes of a file.
Syntax
Setattr path,attributes
Example
Setattr “c:\dropbox\janus.doc” vbreadonly+vb hidden
In this example, the file called janus.doc (found in the c:\dropbox) would now be set to a
ReadOnly, Hidden file.
Mkdir function
The Microsoft Excel
MKDIR statement allows you to create a new folder or directory.
Syntax
Mkdir path
Example
Mkdir
“c:\test\excel”
The c:\Test directory
must already exist. The MKDIR statement will only attempt to create the Excel directory
under the c:\Testdirectory. It will
not create the c:\Test directory
itself.
No comments:
Post a Comment