CharlieT302
Instructor
Hi All,
I have a vba procedure that checks to see if a spreadsheet exists before creating it. I can use a DIR function to do this.
Currently:
If DIR("C:\Documents and Settings\My Documents\Temp_Data.xls") = "" then
Docmd.TransferSpreadsheet ...
else
MsgBox "Complete"
However, I want to check for the file in the MY Documents folder regardless of the computer or user logon.
I have tried:
If DIR("\\%UserProfile%\My Documents\Temp_Data.xls") then...
When I try the %UserProfile% approach, it creates the spreadsheet whether it exists or not. Obviously I have an error in code.
Any suggestions?
I have a vba procedure that checks to see if a spreadsheet exists before creating it. I can use a DIR function to do this.
Currently:
If DIR("C:\Documents and Settings\My Documents\Temp_Data.xls") = "" then
Docmd.TransferSpreadsheet ...
else
MsgBox "Complete"
However, I want to check for the file in the MY Documents folder regardless of the computer or user logon.
I have tried:
If DIR("\\%UserProfile%\My Documents\Temp_Data.xls") then...
When I try the %UserProfile% approach, it creates the spreadsheet whether it exists or not. Obviously I have an error in code.
Any suggestions?