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

Need code for generic user in Docmd.TransferSpreadsheet??

Status
Not open for further replies.

coder30

Programmer
Apr 7, 2006
16
US
In my Docmd.TransferSpreadsheet line in the code below, I need the syntax or wildcard that will allow me to export this report to any user's desktop. I was told %username%, but that does not work. Does anyone have any ideas?



'------------------------------------------------------------
' PS_Contract_Perf_by_Qtr
'
'------------------------------------------------------------
Function PS_Contract_Perf_by_Qtr()
On Error GoTo PS_Contract_Perf_by_Qtr_Err

DoCmd.SetWarnings False
' Transfer Data to Template
DoCmd.TransferSpreadsheet acExport, 8, "Contract Purchases by Quarters", "C:\Documents and Settings\%username%\Desktop\QuikReports\PSContractPerformanceByQtr.xls", True, "Data"
' Open PS Contract Performance By Qtr
DoCmd.RunMacro "Open Contract Perf by Qtr", , ""


PS_Contract_Perf_by_Qtr_Exit:
Exit Function

PS_Contract_Perf_by_Qtr_Err:
MsgBox Error$
Resume PS_Contract_Perf_by_Qtr_Exit

End Function
 
Try:

[tt]DoCmd.TransferSpreadsheet acExport, 8, "Contract Purchases by Quarters", "C:\Documents and Settings\" & Environ("Username") & "\Desktop\QuikReports\PSContractPerformanceByQtr.xls", True, "Data"[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top