Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Returning the My Documents instead of actual path

Status
Not open for further replies.

sness

Programmer
Dec 29, 2003
5
US
This is a VBA/VBScript combo type issue. I have written a vbScript that uses GetAbsolutePathName and it works great. I use ScriptCriptor program to compile it into an .exe file and the .exe file also works great. Then when I use the Shell command to run the script in MS Access Form VBA code, the program reports my "My Documents" path instead of the accurate information. Does anyone have ideas of what to try to fix this?
 
Maybe try posting your code / posting in the VBScript forum...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
OK. Here you go. 3 files.

The MS Access DB, the vbs file and the exe file. Scriptcryptor was used to convert the .vbs to the .exe. They both are the same code.

Take these three files and put them in any drive (not my documents), for Example c:\Fred or any place. Run the .vbs, it should report the path. Run the .exe, same thing. Then try out the DB. When you call the program from within the DB with the Shell command, "My documents" is returned and this is not correct.

I have deleted the "My documents" as the default directory from within the MS Access program, that did not resolve the issue.

Thanks a lot. Sue.
 
 http://www.box.net/files#0:f:22444810

Your link requires a login name and password :-(

Your code here would be helpful....

Have fun.

---- Andy
 
instead of the accurate information
Which information ?
What is displayed in the debug window (Ctrl-G) when you execute the following code?
Debug.Print CurDir
Debug.Print CurrentDb.Name
Debug.Print CurrentProject.Path

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV.

Thanks, this does help.

It returns this:
C:\Documents and Settings\SNess\My Documents
C:\ThisFolder\MyDBFile.mdb
C:\ThisFolder

The CurrentProject.Path is what I need, but I need to be able to return it through the VBScript part of the code, which that DOES, except when you run it via a Shell command.

So when I run my VBScript all by itself, it returns C:\ThisFolder

When I run it via the Shell command in VBA, it returns the c:\Documents and settings\SNess\My Documents.

I need for the VBScript to know the path to the related files for reading and writing values either to the Access DB or to text files, none of which will be located in the Documents and Settings area.

Hmmm. Probably need to set the CurDir to be the same as the CurrentProject.Path.

Thanks!
Sue
 
Have a look at the ChDir instruction:
ChDir CurrentProject.Path
Shell ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks again.

This worked excellently, as well as:

'Application.SetOption "Default Database Directory", CurrentProject.Path

Both worked great.

Thank you for your help!
Sue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top