I have no experience of scheduling Excel tasks; therefore I cannot comment.
If you Start | Run [Schedule] the following:
"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /p c:\ "book1.xls"
where:
1. you are overriding the default path to c:\ (specify your location)
2. making Excel to open workbook book1.xls (specify your name) located in c:\
Your code/macro can run automatically if you include it in or call it from
the Workbook_Open event. In this event, you can save the updated workbook at
your desired location using ActiveWorkbook.SaveAs (see help file)
In order to find out how excel was started, you might try in ThisWorkbook
module:
Private Declare Function GetCommandLine Lib "kernel32" Alias
"GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal
lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As
Any, pSrc As Any, ByVal ByteLen As Long)
Private Function CommandLine() As String
Dim RetCode As Long, RetLength As Long
Dim RetBuffer As String
RetCode = GetCommandLine()
RetLength = lstrlen(RetCode)
If RetLength > 0 Then
CommandLine = Space$(RetLength)
CopyMemory ByVal CommandLine, ByVal RetCode, RetLength
Debug.Print CommandLine
End If
End Function
Your immediate window shows:
"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /p c:\
Perhaos the /p switch is your key to knowing that Excel is running as a
scheduled task?