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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ascertaining current folder

Status
Not open for further replies.

furtivevole

Technical User
Jun 21, 2001
84
GB
From Access, I want to be able to export an .rtf file to the same folder in which the .mdb is located. (This folder can't be hardcoded beforehand, and it will be on a network drive.)

How do I ascertain the "current" folder using VBA? CurDir wants to send me off to C:\winnt\....\profiles.


TIA, Linnet
 
Hi John

In the interim, I'd worked out another way. Less elegant but it seems to work.

Code:
Dim strCurLoc As String         'current location
Dim intM As Integer             'counter
strCurLoc = MDBLocation         '= database location
    ' from right, find first occurance of backslash
    For intM = Len(strCurLoc) To 1 Step -1
        If Mid(strCurLoc, intM, 1) = "\" Then
            strCurLoc = Left(strCurLoc, intM)
            GoTo <somewhere else>     'jump out of loop
        End If
    Next
Linnet
 
John (& all others)

Sorry, missed something off here just now, so here's the complete code.

Function MBDLocation() as string
MDSLocation = DBengine(0).databases(0).Name
end function

....
Function <somefunction>
Dim strCurLoc As String 'current location
Dim intM As Integer 'counter
strCurLoc = MDBLocation '= database location
' from right, find first occurance of backslash
For intM = Len(strCurLoc) To 1 Step -1
If Mid(strCurLoc, intM, 1) = &quot;\&quot; Then
strCurLoc = Left(strCurLoc, intM)
GoTo <somewhere else> 'jump out of loop
End If
Next
...
end function

Linnet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top