robsking
asked on
Transferspreadsheet to desktop of current logged on user in XP?
I'm trying to export a query in xls format onto the desktop of the current logged on user. This sub is in a form. "all users" will not work becuase I don't have admin access to the pc. I need another workaround.
???= the username of the person logged onto the computer.
Any solutions?
Thanks
sample:
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "C:\Documents and Settings\???\Desktop\Pipel ine Report", True, ""
End Sub
???= the username of the person logged onto the computer.
Any solutions?
Thanks
sample:
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "C:\Documents and Settings\???\Desktop\Pipel
End Sub
??? = %username%
or for a more accurate and flexible option
remove all path and replace with
"%userprofile%\desktop"
that will give flexibility for profiles not in the DEFAULT location
hth
CHAD
remove all path and replace with
"%userprofile%\desktop"
that will give flexibility for profiles not in the DEFAULT location
hth
CHAD
In access you can not use the % % style, you have to use the environ function:
environ("username")
environ("userprofile")
environ("username")
environ("userprofile")
ASKER
Both don't work. If I put my username name in, then it works only for me.
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "C:\Documents and Settings\%username%\Deskto p\Pipeline Report", True, ""
End Sub
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "%userprofile%\Desktop\Pip eline Report", True, ""
End Sub
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "C:\Documents and Settings\%username%\Deskto
End Sub
Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "%userprofile%\Desktop\Pip
End Sub
yeap, sorry wrong answer to theright questions
try this code pasted here
http://www.mvps.org/access/api/api0008.htm
this will give you the username of the current network user
try this code pasted here
http://www.mvps.org/access/api/api0008.htm
this will give you the username of the current network user
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks heer2351! Just what I was looking for.
I think I was nuking it a bit too much. LSNED