Microsoft KB Archive/66910

WordBASIC Macro to Obtain Current Path or Directory

PSS ID Number: Q66910 Article last modified on 07-20-1993

1.00 1.10 1.10a 2.00 WINDOWS

Summary: The following macro obtains the current path and directory of Microsoft Word for Windows and store them in the variables CurrentPath$ and CurrentDirectory$: Sub MAIN  CurrentPath$  = Files$(".")  CurrentDirectory$  = Left$(CurrentPath$, Len(CurrentPath$)-1)  MsgBox "The current path is " + CurrentPath$  MsgBox “The current directory is” + CurrentDirectory$ End Sub If the current directory is C:when you run the macro, CurrentPath$ is set to C: and CurrentDirectory$ is set to C:. Note the second slash in the CurrentPath$ example.

More Information: Files$(FileSpec$ ) is a WordBASIC function that returns the first file matching the parameter FileSpec$. A single dot (.) is a special DOS filename referring to the current directory.

Reference(s): “Microsoft Word for Windows Technical Reference,” page 100 “Microsoft Word for Windows and OS/2 Technical Reference,” pages 178-179

Additional reference words: 1.0 1.1 1.1a 1.00 1.10 1.10a w4wmacro 2.0 2.00