View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Workbooks.Open fails in scheduled job

What is the error message that you are getting on the line that fails? I am
wondering if you have the correct full file name.

Open the workbook Fence Check Rota.xlsm

Open the VBA editor

Open the Immediate window. (Menu item View - Imediate window or Ctrl/G)

Copy and paste the following into the immediate window and press Enter.

? ThisWorkbook.FullName

Copy the returned result into your code.

--
Regards,

OssieMac


"Old Man River" wrote:

I am trying to run this code from a scheduled job. It works fine if I use the
Command Line (pasted below it) which is replicated in the scheduled job. The
Job ran succesfully, for which it had to wake the machine, but fails at the
Workbooks.Open statement. Any suggestions please.

Option Explicit

Sub Auto_Open()
'Stop
'Load and Work in the Fence Check Rota spreadsheet
Workbooks.Open _
Filename:= "C:\Users\Alan\Documents\HSC\Fence Check\Fence
Check Rota.xlsm"
Application.Run "'Fence Check Rota.xlsm'!Email_Turn"
ActiveWorkbook.Save
ActiveWindow.Close
'Now close the Fence Check Auto Run spreadsheet or quit XL if notthing
else open.
If Application.Workbooks.Count < 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
End Sub

The command line is

"C:\Program Files\Microsoft Office\Office12\Excel.exe" /r
"C:\Users\Alan\Documents\HSC\Fence Check\Fence Check Auto Run.xlsm"

Running Vista

Thanks!