Run Time Error 1004 file path cannot be found

route217 used Ask the Experts™
Hi Experts

I am getting the following error and the file path is correct 100% not sure whats wrong here:-

Private Sub Export_Weekly_SLA___RPO_Click()

DoCmd.Echo True, "Exporting, Please Wait.........."

Dim xlPath As String, xlObj As Object
Dim rs As DAO.Recordset, sql As String

xlPath = "\\TW01251\Output Files\Reporting Template\"

Set xlObj = CreateObject("excel.application")
     xlObj.Workbooks.Open xlPath & "Sample_Template.xls"

on line xlObj.Workbooks.Open xlPath & "Sample_Template.xls"
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Nothing to say about the code.

I suggest you go into the debug/Immediate window and do..

?dir( "\\TW01251\Output Files\Reporting Template\Sample_Template.xls")

and check that it returns the file name.


When I type in the file path name how would I see the return?
If the path does exist then you get the filename.
If the path or filename does not exist then you get nothing.

(Make sure you hit Enter at the end of the line)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial