Microsoft Office Tutorials and References
In Depth Information
Windows API Calls
Function GetExecutable(strFile As String) As String
Dim strPath As String
Dim intLen As Integer
strPath = Space(255)
intLen = FindExecutableA(strFile, “\”, strPath)
GetExecutable = Trim(strPath)
End Function
Figure 11-19 shows the result of calling the GetExecutable function, with an argument of the
filename for an MP3 audio file. The function returns the full path of the application that’s
associated with the file.
Figure 11-19: Determining the path and name of the application associated with a particular file.
This example is available on the companion CD-ROM. The filename is file
association.xlsm .
Determining disk drive information
VBA doesn’t have a way to directly get information about disk drives. But with the assistance of
three API functions, you can get just about all the information you need.
Figure 11-20 shows the output from a VBA procedure that identifies all connected drives,
determines the drive type, and calculates total space, used space, and free space.
The code is rather lengthy, so I don’t list it here, but the interested reader should be able to figure
it out by examining the code on the CD-ROM.
This example is available on the companion CD-ROM in a file named
drive information.xlsm .
Search JabSto ::

Custom Search