Robit010
Robit010

Reputation: 63

VBS Running Macro Enabled Workbook Error 800A9C68

I'm having a small issue with a VBS script I pieced together from the internet.

Dim xlApp, xlBook


Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Open("LOCATION", 0, True)


xlapp.Visible = True

xlApp.Run "RefreshAdj"

xlBook.Close False
set xlBook = Nothing

xlApp.Quit
Set xlApp = Nothing

WScript.Echo "Finished."
WScript.Quit

It will run off task scheduler but it always gives this error.

Line: 11
Char: 1
Error: Unknown runtime Error
Code: 800A9C68
Source: Microsoft VBScript runtime Error

Its not that big of a deal, but slightly annoying because it will not run the next day until someone clears the dialog box for this error.

Upvotes: 0

Views: 6140

Answers (2)

Hemant
Hemant

Reputation: 1

My macro is closing the Excel as well with Activeworkbook.Close and VBScript is also closing the Excel application which is not open, thus gives me error: objExcel.Application.Quit. So I removed ActiveWorkbook.Close from the macro and now it works fine.

Upvotes: 0

davidj
davidj

Reputation: 58

I've just had the same problem in a script where I updated the data in a sheet, saved the file with a different name and then did

ActiveWorkbook.Close

I think the problem is that by saving the file with a different name somehow Excel gets confused as to what the ActiveWorkbook is. I had the same error with ThisWorkbook.

Upvotes: 2

Related Questions