Function File Names Class

MakePathAbsolute

Creates an absolute path name from one that may be relative.

Signature (Visual Basic / VBA)

Public Function MakePathAbsolute( _
    ByVal vPath As Variant _
    ) As Variant

Code Example

    Assuming
       CurDir$ = "C:\WINDOWS"
    for example
       MakePathAbsolute("WIN.INI") = "C:\WINDOWS\WIN.INI"
       MakePathAbsolute("\WIN.INI") = "C:\WIN.INI"
       MakePathAbsolute("C:WIN.INI") = "C:\WINDOWS\WIN.INI"
       MakePathAbsolute("C:\WIN.INI") = "C:\WIN.INI"
       MakePathAbsolute("C:\TEMP\.\WIN.TMP") = "C:\TEMP\WIN.TMP" ' #5
       MakePathAbsolute("C:\TEMP\..\WIN.TMP") = "C:\WIN.TMP" ' #6

Parameters

Parameter Description
vPath The path name that is to be made absolute. Function returns Null if vPath is Null or cannot be fixed-up to a string.

Notes & Version History

Definition Absolute paths are those that specify a direct path to a file from the root of some named drive. All other path names are relative.
Note Function also removes substrings like "\.\" or "\..\" as in examples #5 and #6.