Access reports to files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In ACCESS 2003 -

I can write as many files as I need now, but I have to hard code the output
path and filename. Filenames are working, but isn't there a default string
for the path to any user's MyDocuments folder?

Thanks
 
Put this followin code in a Module in your database and call it from
anywhere in your database to get the full pathname to the current users
MyDocuments directory.

' ------ Code Start ------
Private Declare Function SHGetFolderPath Lib "shfolder.dll" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwReserved As Long, _
ByVal lpszPath As String) As Long

Private Const MAX_LENGTH = 260

Public Function MyDocsPath() As String
' Return the full path to the current users MyDocuments Folder
Dim buff As String

buff = Space$(MAX_LENGTH)
If SHGetFolderPath(Application.hWndAccessApp, &H5, -1, 0, buff) = 0 Then
MyDocsPath = Left(buff, InStr(1, buff, Chr(0)) - 1)
Else
MyDocsPath = ""
End If
End Function
' ------ Code Ends ------
 
Back
Top