Link to home
Start Free TrialLog in
Avatar of bjs19
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
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

have you tried app.path ?
Avatar of bjs19
bjs19

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
Avatar of SilentRage
SilentRage

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh, here's some related VB functions:

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
Avatar of bjs19

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