Error 800A9C68 running VBS using task scheduler

David Montoya

New Member
Joined
Apr 25, 2018
Messages
49
Gentlemen,

I am running this code via task scheduler, and the workbook is closed when it runs. At the end of the process, it gives me the following error; however, all the expected processes are perfect. I have also run the macro manually, and it works as expected. I suspect the VBS code has something wrong:

Script: "Location path of the VBS script"
Line: 2
Char: 1
Error: Unknown runtime error
Code: 800A9C68
Source: Microsoft VBSScript runtime error

The following is the code:
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'I:\Administration\Trade Compliance\Import Compliance\Trade Data\Daily Files\Master DB Daily Appends.xlsm'!Module7.Trade_Data_Daily_Process"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing

Thanks in advance for your assistance.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,874
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
Hello David,

Try changing the line...
Code:
objExcel.Application.Quit

To just this...
Code:
objExcel.Quit
 

David Montoya

New Member
Joined
Apr 25, 2018
Messages
49
Hi Leith,

I have done the suggested change, and now I am getting the following:

Run-time error '13':
Type mismatch

Thanks in advance for your assistance.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,714
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Try adding:

Code:
objexcel.visible = True

to the start and see if there is an error message in Excel.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,980
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Looks like you also posted the question over here: https://www.mrexcel.com/forum/excel...a9c68-running-vbs-using-task-scheduler-2.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will typically be locked or deleted (rule 12 here: Forum Rules).
If you do not receive a response, you can "bump" it by replying to it again, though we advise you to wait 24 hours before doing and not to bump a thread more than once a day.

 

David Montoya

New Member
Joined
Apr 25, 2018
Messages
49
Dear Joe4,


Yes, I did the posting back in April/18, and never received a reply to it. Then I thought that since I was posting to a 2014 posting, maybe was the reason to not getting any replies. Once I did a new post with the same question, I got a reply.


Pardon me if I have caused an infringement to the forum rules.


Best regards
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,980
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Yes, I did the posting back in April/18,
I think you mean last month (your post in that thread is from June 2018)!
Its rather odd that someone replied to that thread today, over a month since you posted the question, but just one day after you posted the question in a new thread (that is how I saw it)!
Not sure why they answered that thread and not your new one...
 

David Montoya

New Member
Joined
Apr 25, 2018
Messages
49
Dear,

I have modified the VBS to include the visibility option, and all the Excel macros run as expected without any error.

I have noticed that when I included the visibility at the secondary line of the VBS script the error changed from Line 2 to Line 3:

Script: "Location path of the VBS script"
Line: 3
Char: 1
Error: Unknown runtime error
Code: 800A9C68
Source: Microsoft VBSScript runtime error

From the test I have done, it appears to me that the trigger of the error is at my second line of my code above mentioned, but do not understand what it refers to "Char: 1"

Any other suggestion is appreciated.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,714
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Perhaps try opening the workbook explicitly first:

Code:
Dim wb
Set objExcel = CreateObject("Excel.Application")
set wb = objexcel.workbooks.open("I:\Administration\Trade Compliance\Import Compliance\Trade Data\Daily Files\Master DB Daily Appends.xlsm")
objExcel.Run "'" & wb.name & "'!Module7.Trade_Data_Daily_Process"
objExcel.DisplayAlerts = False
wb.close false
objExcel.Quit
Set objExcel = Nothing
 

Watch MrExcel Video

Forum statistics

Threads
1,129,876
Messages
5,638,788
Members
417,052
Latest member
Noobest

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top