How to tell if Excel object exisits

  • Thread starter Thread starter shaggles
  • Start date Start date
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?
 
Use the Dir() function:


sub t3()
If Dir("c:\autoexec.bat") = "autoexec.bat" Then
MsgBox "Yes"
End If
End Sub
 
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)





.
 
Back
Top