Results 1 to 5 of 5
  1. #1
    faeren is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    4

    Macro having issues when run on Windows Scheduler

    I have a macro in microsoft access that I have set-up on a windows scheduler. It's supposed to run every morning to load data before I come in. When I run the code while I'm logged into the computer the code runs fine, but when it runs on the scheduler I always get the following error:



    error code: 1004
    Description: Microsoft Office Excel cannot access the file 'C:\MLX Zipped Files\Master Trade Date Activity 2222_500448_4636_PP.XLS'. There are several possible reasons:
    • The file name or path does not exist.
    • The file is being used by another program.
    • The workbook you are trying to save has the same name as a currently open workbook.

    For some reason the code always hangs on saving the excel file changes that have been. The following code line:

    eWBK.SaveAs sDestination, xlOpenXMLWorkbook, "", "", , , xlNoChange, xlLocalSessionChanges

    I don't understand why it has trouble saving this file when running on the macro, because when I kick off the code it runs fine.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    When I've had these types of problems it's been a permissions issue. You say it runs fine when you're logged in but not on the scheduler. Does that mean the computer isn't logged in when it runs that way? If not, have you tried locking the workstation rather than logging out and seeing if it runs correctly then?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    faeren is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    4
    When I kick off the code to run in the code window it runs fine. If I run the macro to start the code it works, but If I run the code from the scheduler it errors out on saving the excel sheet everytime. I've tried running the scheduler when I'm logged in, I've tried logging out, locking the computer, unlocking the computer and running the code while I'm logged. I've tried checking the library references, I've had permissions changed on the computer so that I'm the administrator. I've done everything I can think of. The code works fine when I log in and run it from the code window in access, but won't save the excel file when run on the scheduler.

  4. #4
    faeren is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    4

    Issue Fix

    I finally found the issue. I came across an old post while googling that someone was having the same issue when Office COM scripting involved saving office files.

    The scheduled tasks that wouldn't function all involved Office COM scripting where I'd save off Excel and Word files. I fixed the Excel scripts by creating a folder called
    c:\windows\syswow64\config\systemprofile\desktop. This desktop folder wasn't present before and I googled across a posting that it had to be there in order for the Excel COM function to work as a scheduled task. Without this desktop folder the Excel COM would fail while trying to perform a SaveAs() to write out the final document.

    I created this folder and now the scheduler runs fine.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That's a new one on me, and thanks for posting back with the solution. Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 02-09-2012, 02:27 PM
  2. Replies: 13
    Last Post: 07-18-2011, 10:05 AM
  3. Replies: 3
    Last Post: 07-15-2010, 05:53 PM
  4. Replies: 2
    Last Post: 05-19-2010, 02:01 PM
  5. Access Scheduler
    By Chockness in forum Access
    Replies: 0
    Last Post: 03-31-2010, 11:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums