Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Workbooks.Open fails in scheduled job

Thanks for responding.

The File name is fine - when opening the Excel spreadsheet with the
Auto_Open code manually it works perfectly.

What I should have added was that the when I looked Excel was still open
with a file recovery panel showing that both the Auto Run workbook and Rota
worksheet had both been "Recovered". Both were present and the Rota
worksheet had obviously been opened as it had a Today reference in a cell
which had been updated. The Auto Run workbook displayed a Prompt saying the
code had failed and displaying a error code (I'm kicking myself for not
noting the details) with buttons including Debug which I pressed and the line

Workbooks.Open _
Filename:= "C:\Users\Alan\Documents\HSC\Fence Check\Fence
Check Rota.xlsm" <--- in the code this is on same line as above.

was highlighted in Yellow.

This morning (02:30 GMT) the task Failed completely with the following
message in Scheduler:

Task Scheduler failed to start "\Fence Check Rota" task for user
"Alan-Laptop\Alan". Additional Data: Error Value: 2147943726.

I will delete the task and re add it to the scheduler. But first I'll force
it to run and see if I get any more info.

"OssieMac" wrote:

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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Workbooks.Open fails in scheduled job

Think I might have found the problem

The ActiveWindow.Close should have been ActiveWorkbook.Close !!!

Thanks for being there! I'll post another reply if it all seems to work OK.

"OssieMac" wrote:

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Workbooks.Open fails in scheduled job

Task ran as programmed last night - problem solved - Thanks guys.

"Old Man River" wrote:

Think I might have found the problem

The ActiveWindow.Close should have been ActiveWorkbook.Close !!!

Thanks for being there! I'll post another reply if it all seems to work OK.

"OssieMac" wrote:

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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbooks.Open fails in scheduled job joel[_154_] Excel Programming 1 November 2nd 09 02:13 PM
How to open multi-workbooks w/ Window Scheduled Task? March Excel Programming 2 January 21st 09 07:41 PM
Open the Excel Workbooks in Windows Scheduled Task March Excel Programming 0 January 20th 09 06:08 PM
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"