Link to home
Start Free TrialLog in
Avatar of robsking
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\Pipeline Report", True, ""
End Sub
Avatar of chad
chad

??? = %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
In access you can not use the % % style, you have to use the environ function:

environ("username")
environ("userprofile")
Avatar of robsking

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%\Desktop\Pipeline Report", True, ""
End Sub

Private Sub ExportXLS_Click()
DoCmd.TransferSpreadsheet acExport, 8, "qryviewpipeline", "%userprofile%\Desktop\Pipeline Report", True, ""
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
ASKER CERTIFIED SOLUTION
Avatar of heer2351
heer2351

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks heer2351! Just what I was looking for.
I think I was nuking it a bit too much.  LSNED