3

I'm trying to set up a basic task in the Windows Task Scheduler that opens an Excel file every day. I've done this successfully in the past, but for some reason on the Windows Server 2012 OS I'm using when I try to open the file I get prompted with how do you want to open this type of file?

Task Scheduler Example

Is there a way to automatically select Excel as the program used to run the file for this task?

4 Answers 4

5

You need to specify the Full path to the Excel.exe application executable as well as the workbook to open.

Location of Office Programs (64-bit Office on 64-bit Windows Server 2012)

  • Microsoft Office 2013
           "%PROGRAMFILES%\Microsoft Office\Office15\EXCEL.EXE"
  • Microsoft Office 2010
           "%PROGRAMFILES%\Microsoft Office\Office14\EXCEL.EXE"
  • Microsoft Office 2007
           "%PROGRAMFILES%\Microsoft Office\Office12\EXCEL.EXE"
  • Microsoft Office 2003
           "%PROGRAMFILES%\Microsoft Office\Office11\EXCEL.EXE"
  • Microsoft Word 2002
           "%PROGRAMFILES%\Microsoft Office\Office10\EXCEL.EXE"
  • Microsoft Word 2000
           "%PROGRAMFILES%\Microsoft Office\Office\EXCEL.EXE"

For a 32-bit Office version on a 64-bit operating system substitute %PROGRAMFILES(x86)% for %PROGRAMFILES%.

Example of command line:

"%PROGRAMFILES%\Microsoft Office\Office14\EXCEL.EXE" "C:\Users\user\Documents\MyWorkbook.xlsx"

To be clear, this means in the Task Scheduler GUI, you need to put the filepath for EXCEL.EXE in the Program/script line and the filepath for the custom Excel file you want to open in the Arguments line.

Additional command lines options are available to open as read only, etc. See Command-line switches for Excel.

Sign up to request clarification or add additional context in comments.

Comments

1

There is a simple way to do this:

Create a .bat file with the following content:

start Excel.exe "C:\Users\User_01\Documentos\file01.xlsm"

You should start this in the windows scheduler.

Comments

0

This has solved it for me:

32Bit:

C:\Windows\System32\config\systemprofile\Desktop

64Bit:

C:\Windows\SysWOW64\config\systemprofile\Desktop

Comments

0

Three important steps - How to Task Schedule an excel.xls(m) file

simply:

  1. make sure the .vbs file is correct
  2. set the Action tab correctly in Task Scheduler
  3. don't turn on "Run whether user is logged on or not"

IN MORE DETAIL...

Here is an example .vbs file:

'
'   a .vbs file is just a text file containing visual basic code that has the extension renamed from .txt  to .vbs

 'Write Excel.xls  Sheet's full path here
 strPath = "C:\RodsData.xlsm" 

'Write the macro name - could try including module name
strMacro = "Update" '    "Sheet1.Macro2" 

'Create an Excel instance and set visibility of the instance
Set objApp = CreateObject("Excel.Application") 
objApp.Visible = True   '   or False 

'Open workbook; Run Macro; Save Workbook with changes; Close; Quit Excel
Set wbToRun = objApp.Workbooks.Open(strPath) 
objApp.Run strMacro     '   wbToRun.Name & "!" & strMacro 
wbToRun.Save 
wbToRun.Close 
objApp.Quit 

'Leaves an onscreen message!
MsgBox strPath & " " & strMacro & " macro and .vbs successfully completed!",         vbInformation 
'

In the Action tab (Task Scheduler):

set Program/script: = C:\Windows\System32\cscript.exe

set Add arguments (optional): = C:\MyVbsFile.vbs

Finally, don't turn on "Run whether user is logged on or not".

That should work. Many people also need the following two folders created on their machine:

32Bit:

C:\Windows\System32\config\systemprofile\Desktop  

64Bit:

C:\Windows\SysWOW64\config\systemprofile\Desktop

Apparently Excel needs these folders if it's not run interactively. Create both folders even if you are on a 64-bit OS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.