bjs19
asked on
Getting the current working directory
Is there a system command in VB to retrieve the current working directory?
I want open a word file using VBA and I'd like to have the CWD as a point of reference than hard coding a full path.
I apologize for the simplicity of this question but I'm trying to move into VB from VC++.
Thanks,
Ray
I want open a word file using VBA and I'd like to have the CWD as a point of reference than hard coding a full path.
I apologize for the simplicity of this question but I'm trying to move into VB from VC++.
Thanks,
Ray
have you tried app.path ?
ASKER
I tried app.path but it only give me where word.exe is located. I'd like to grab where the database file is kept.? How could I grab the location of the access db?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh, here's some related VB functions:
Change current directory
ChDir "C:\windows"
Change current drive
ChDrive "C:\"
Change current directory
ChDir "C:\windows"
Change current drive
ChDrive "C:\"
You can use the CurDir function to find the current directory.
This is a paste from VBA help
----------Paste starts here---------
Returns a Variant (String) representing the current path.
Syntax
CurDir[(drive)]
The optional drive argument is a string expression that specifies an existing drive. If no drive is specified or if drive is a zero-length string (""), CurDir returns the path for the current drive
----------End of paste------------
Alternatively, you can use the file system object:
In References check Microsoft Scripting Runtimes.
Then use the GetAbsolutePathName function to get the exact location of the database file.
If I did not understand you correctly, you can also press F2 and browse the other Get.. functions exposed by the Scripting library, maybe you will find the most appropriate one to solve your problem
Dabas
This is a paste from VBA help
----------Paste starts here---------
Returns a Variant (String) representing the current path.
Syntax
CurDir[(drive)]
The optional drive argument is a string expression that specifies an existing drive. If no drive is specified or if drive is a zero-length string (""), CurDir returns the path for the current drive
----------End of paste------------
Alternatively, you can use the file system object:
In References check Microsoft Scripting Runtimes.
Then use the GetAbsolutePathName function to get the exact location of the database file.
If I did not understand you correctly, you can also press F2 and browse the other Get.. functions exposed by the Scripting library, maybe you will find the most appropriate one to solve your problem
Dabas
ASKER
That is exactly what I was looking for. Short and sweet. I'm able to set and grab the file paths as I want now. That so much
Ray
Ray