3

I have an Access 2003 DB, which has a VBA module. The module function points to an Excel file.

The function is calling the Excel file through the command line like this: Shell "Excel \\server\dir\filename.xls", vbMaximizedFocus

The DB opens, the function gets triggered, and I get Run-timer error '53': File not found

I know that the Excel file exists, and I am able to open it. I have the security permissions to be able to access folders in the filepath.

What I already tried:

decompile+compact+recompile the DB, using the instructions here.

I am still getting the same error. Can anyone suggest other causes/solutions?

minor edit - content remains the same.

Community
  • 1
  • 1
sion_corn
  • 3,043
  • 8
  • 39
  • 65
  • Are you able to access the file `\\server\dir\filename.xls` from a file explorer window? – Shiva Dec 11 '13 at 15:40

2 Answers2

1

Refer to the mapped network drive (letter). Check your immediate window:

?dir("N:/dir\filename.xls") 

You can also open a workbook as follows (if you want more flexibility):

Dim oExcel As Excel.Application
Set oExcel = CreateObject("Excel.Application")

oExcel.visible = true
oExcel.Workbooks.Open ("\\server\dir\filename.xls")

oExcel.Quit 'close 
html_programmer
  • 18,126
  • 18
  • 85
  • 158
  • 1
    What was ultimately the reason for the path not being recognized? – html_programmer Dec 12 '13 at 14:57
  • 2
    for some reason, typing 'excel' into the shell would not launch excel. but if i entered the full path of excel.exe, it was able to launch. since the path might be different on different machines, and to account for future software upgrades, i decided to just call the excel object. – sion_corn Dec 12 '13 at 15:00
1

I can't reproduce the file not found error. I adapted your code as follows, but it opens the workbook file without error.

Const cstrFile = "\\HP64\share\Access\temp.xls"
If Len(Dir(cstrFile)) = 0 Then
    MsgBox "File '" & cstrFile & "' not found."
Else
    Shell "Excel " & cstrFile, vbMaximizedFocus
End If

Alternatively, you could create an Excel application instance and then open the file. However I'm skeptical whether that would avoid the not found error.

Dim objExcel As Object 'Excel.Application
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Open cstrFile

' do stuff here
objExcel.Quit
Set objExcel = Nothing
HansUp
  • 95,961
  • 11
  • 77
  • 135