# Error 800A9C68 running VBS using task scheduler



## David Montoya (Jul 11, 2018)

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:

```
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.


----------



## Leith Ross (Jul 11, 2018)

Hello David,

Try changing the line...

```
objExcel.Application.Quit
```

To just this...

```
objExcel.Quit
```


----------



## David Montoya (Jul 12, 2018)

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 (Jul 12, 2018)

Try adding:


```
objexcel.visible = True
```

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


----------



## Joe4 (Jul 12, 2018)

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 (Jul 12, 2018)

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 (Jul 12, 2018)

> 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 (Jul 12, 2018)

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 (Jul 13, 2018)

Perhaps try opening the workbook explicitly first:


```
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
```


----------



## David Montoya (Jul 13, 2018)

Now the error displays "Line: 4" instead of "Line: 2"


----------



## David Montoya (Jul 11, 2018)

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:

```
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.


----------



## David Montoya (Jul 19, 2018)

I still believe the problem is with the VBS Script in line 2, but have not been able to resolve. Any other suggestion?


----------



## Naveen5670 (Dec 28, 2021)

David Montoya said:


> 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:
> 
> ...


I'm also using the same code and getting the same error. did you find any solution?


----------

