SOLVED

Access Export file name with userprofile variable

Copper Contributor

Does anyone know if there is a way to set an export file name, in an export macro, based on the windows login ID location.  Something like

C:\users\%userprofile%\........ so it saves to each particular users folder location for whoever does the export.

 

That format works in dos prompt but doesn't work in the macro.

 

(This is in a macro not in the code using docmd)

3 Replies

@Barry_R 

 

can you create a Function that will return you the Path + filename:

in a Module, add this code:

Public Function MyDocumentFile(ByVal filName As String) As String
MyDocumentFile = Environ$("userprofile") & "\documents\" & filName
End Function

 

then you can call the function from your Macro:

 

macro.png

best response confirmed by Barry_R (Copper Contributor)
Solution

@arnel_gp 

 

Thank you that worked and you provided all the info clearly for me to follow. 

Extremely helpful! - much gratitude for your insightful example!
1 best response

Accepted Solutions
best response confirmed by Barry_R (Copper Contributor)
Solution

@arnel_gp 

 

Thank you that worked and you provided all the info clearly for me to follow. 

View solution in original post