How to tell if Excel object exisits

S

shaggles

I have some code to export a report to Excel using
DoCmd.OutputTo but I want to make it an If...Then
statement where if the Excel file exists then the file is
exported to a differant file name. I've tried
If "C:\Book1.xls" = True...
If "C:\Book1.xls" Is Not Null...
If "C:\Book1.xls" Exists...
If "C:\Book1.xls" Is Object...
But I can't figure out how to write it. Can anyone help
me with this?
 
M

Michael Hopwood

Use the Dir() function:


sub t3()
If Dir("c:\autoexec.bat") = "autoexec.bat" Then
MsgBox "Yes"
End If
End Sub
 
S

shaggles

That worked. Thanks.
-----Original Message-----
Use the Dir() function:


sub t3()
If Dir("c:\autoexec.bat") = "autoexec.bat" Then
MsgBox "Yes"
End If
End Sub

--
Michael Hopwood (Phobos)





.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top