Click to See Complete Forum and Search --> : get Directory Name


Lorna
August 8th, 2001, 03:16 AM
I'm a total newcomer to API functions. From my Access application, I would like to find out in which directory the user is currently working. Any idea how I can do that?

Thanks

Cimperiali
August 8th, 2001, 03:38 AM
'This may help: it is in a command code of a form in access.
private Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (byval nBufferLength as Long, byval lpBuffer as string) as Long
private Function retThePath()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@allapi.net
Dim sSave as string
'create a buffer
sSave = string(255, 0)
'retrieve the current directory
GetCurrentDirectory 255, sSave
retThePath = sSave
End Function

private Sub Comando6_Click()
on error GoTo Err_Comando6_Click
Form.Caption = retThePath
'you could also use:
'Form.Caption = CurDir
Exit_Comando6_Click:
Exit Sub

Err_Comando6_Click:
MsgBox Err.Description
resume Exit_Comando6_Click

End Sub





Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater