c***@gmail.com
2016-03-22 22:05:35 UTC
I have run this script weekly for over 3 years now and it has worked perfectly. However, I recently added 2 more files to open and then close after I run a macro in the xlsm file. Since I added the extra 4 lines of code I have been getting this message:
Script: \\location\000.vbs
Line: 44
Char: 1
Error: The object invoked has disconnected from its clients.
Code: 80010108
Source: (null)
Keep in mind that all of the code that I know I got from Google.
This 000.vbs file is executed from within a Access database that first deletes last weeks Excel files and then creates new Excel files by exporting query results based on a preset date range and then the database vb has a msgBox line that effectively causes pause until the 000.vbs runs. After this 000.vbs runs I click the "OK" box in the database and the vb continues. The purpose of all this mess is to automate weekly reporting that would take hours to do otherwise. In the code below you will see "StaffMeeting.xlsm". That is an Excel file where, once all these files are opened, I run a macro that pulls in information from still another source and does some calculations based on all of these linked xls files and gives all the information that I could be questioned about in the staff meeting.
The code in 000.vbs is as follows
Dim objExcel, objWorkbook1, objWorkbook2, objWorkbook3, objWorkbook4, objWorkbook5, objWorkbook6, objWorkbook7, objWorkbook8, objWorkbook9, objWorkbook10, objWorkbook11, objWorkbook12, objWorkbook13, objWorkbook14, objWorkbook15, objWorkbook16, objWorkbook17, objWorkbook18, objWorkbook19, objWorkbook20, objWorkbook21, objWorkbook22
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook1 = objExcel.Workbooks.Open ("\\location\QtyByDie.xlsx")
Set objWorkbook2 = objExcel.Workbooks.Open ("\\location\QtyByDieWeek.xlsx")
Set objWorkbook3 = objExcel.Workbooks.Open ("\\location\QtyByType.xlsx")
Set objWorkbook4 = objExcel.Workbooks.Open ("\\location\QtyJobsComp.xlsx")
Set objWorkbook5 = objExcel.Workbooks.Open ("\\location\Qty_By_Hour.xlsx")
Set objWorkbook6 = objExcel.Workbooks.Open ("\\location\Dieshop.xls")
Set objWorkbook7 = objExcel.Workbooks.Open ("\\location\Incomplete.xlsx")
Set objWorkbook8 = objExcel.Workbooks.Open ("\\location\ProdSumRep.xls")
Set objWorkbook9 = objExcel.Workbooks.Open ("\\location\QtyYanks.xlsx")
Set objWorkbook10 = objExcel.Workbooks.Open ("\\location\WklyDowntime.xls")
Set objWorkbook11 = objExcel.Workbooks.Open ("\\location\Production.xls")
Set objWorkbook12 = objExcel.Workbooks.Open ("\\location\EDM.xlsx")
Set objWorkbook13 = objExcel.Workbooks.Open ("\\location\Duration.xlsx")
Set objWorkbook14 = objExcel.Workbooks.Open ("\\location\RobotWeekly.xlsx")
Set objWorkbook15 = objExcel.Workbooks.Open ("\\location\CJQuery.xlsx")
Set objWorkbook16 = objExcel.Workbooks.Open ("\\location\YanksAtSetup.xlsx")
Set objWorkbook17 = objExcel.Workbooks.Open ("\\location\PrssCllsByOp.xlsx")
Set objWorkbook18 = objExcel.Workbooks.Open ("\\location\QAMISCH.xlsx")
Set objWorkbook19 = objExcel.Workbooks.Open ("\\location\QtyProjects.xlsx")
Set objWorkbook20 = objExcel.Workbooks.Open ("\\location\QtyTypeMaint.xlsx")
Set objWorkbook21 = objExcel.Workbooks.Open ("\\location\QtyProjects.xlsx")
Set objWorkbook22 = objExcel.Workbooks.Open ("\\location\StaffMeeting.xlsm")
msgBox "Intentional Pause - Run Macro in staff meeting spreadsheet"
objWorkbook1.Close
objWorkbook2.Close
objWorkbook3.Close
objWorkbook4.Close
objWorkbook5.Close
objWorkbook6.Close
objWorkbook7.Close
objWorkbook8.Close
objWorkbook9.Close
objWorkbook10.Close
objWorkbook11.Close
objWorkbook12.Close
objWorkbook13.Close
objWorkbook14.Close
objWorkbook15.Close
objWorkbook16.Close
objWorkbook17.Close
objWorkbook19.Close
objWorkbook20.Close
objWorkbook21.Close
objWorkbook18.Close
Script: \\location\000.vbs
Line: 44
Char: 1
Error: The object invoked has disconnected from its clients.
Code: 80010108
Source: (null)
Keep in mind that all of the code that I know I got from Google.
This 000.vbs file is executed from within a Access database that first deletes last weeks Excel files and then creates new Excel files by exporting query results based on a preset date range and then the database vb has a msgBox line that effectively causes pause until the 000.vbs runs. After this 000.vbs runs I click the "OK" box in the database and the vb continues. The purpose of all this mess is to automate weekly reporting that would take hours to do otherwise. In the code below you will see "StaffMeeting.xlsm". That is an Excel file where, once all these files are opened, I run a macro that pulls in information from still another source and does some calculations based on all of these linked xls files and gives all the information that I could be questioned about in the staff meeting.
The code in 000.vbs is as follows
Dim objExcel, objWorkbook1, objWorkbook2, objWorkbook3, objWorkbook4, objWorkbook5, objWorkbook6, objWorkbook7, objWorkbook8, objWorkbook9, objWorkbook10, objWorkbook11, objWorkbook12, objWorkbook13, objWorkbook14, objWorkbook15, objWorkbook16, objWorkbook17, objWorkbook18, objWorkbook19, objWorkbook20, objWorkbook21, objWorkbook22
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook1 = objExcel.Workbooks.Open ("\\location\QtyByDie.xlsx")
Set objWorkbook2 = objExcel.Workbooks.Open ("\\location\QtyByDieWeek.xlsx")
Set objWorkbook3 = objExcel.Workbooks.Open ("\\location\QtyByType.xlsx")
Set objWorkbook4 = objExcel.Workbooks.Open ("\\location\QtyJobsComp.xlsx")
Set objWorkbook5 = objExcel.Workbooks.Open ("\\location\Qty_By_Hour.xlsx")
Set objWorkbook6 = objExcel.Workbooks.Open ("\\location\Dieshop.xls")
Set objWorkbook7 = objExcel.Workbooks.Open ("\\location\Incomplete.xlsx")
Set objWorkbook8 = objExcel.Workbooks.Open ("\\location\ProdSumRep.xls")
Set objWorkbook9 = objExcel.Workbooks.Open ("\\location\QtyYanks.xlsx")
Set objWorkbook10 = objExcel.Workbooks.Open ("\\location\WklyDowntime.xls")
Set objWorkbook11 = objExcel.Workbooks.Open ("\\location\Production.xls")
Set objWorkbook12 = objExcel.Workbooks.Open ("\\location\EDM.xlsx")
Set objWorkbook13 = objExcel.Workbooks.Open ("\\location\Duration.xlsx")
Set objWorkbook14 = objExcel.Workbooks.Open ("\\location\RobotWeekly.xlsx")
Set objWorkbook15 = objExcel.Workbooks.Open ("\\location\CJQuery.xlsx")
Set objWorkbook16 = objExcel.Workbooks.Open ("\\location\YanksAtSetup.xlsx")
Set objWorkbook17 = objExcel.Workbooks.Open ("\\location\PrssCllsByOp.xlsx")
Set objWorkbook18 = objExcel.Workbooks.Open ("\\location\QAMISCH.xlsx")
Set objWorkbook19 = objExcel.Workbooks.Open ("\\location\QtyProjects.xlsx")
Set objWorkbook20 = objExcel.Workbooks.Open ("\\location\QtyTypeMaint.xlsx")
Set objWorkbook21 = objExcel.Workbooks.Open ("\\location\QtyProjects.xlsx")
Set objWorkbook22 = objExcel.Workbooks.Open ("\\location\StaffMeeting.xlsm")
msgBox "Intentional Pause - Run Macro in staff meeting spreadsheet"
objWorkbook1.Close
objWorkbook2.Close
objWorkbook3.Close
objWorkbook4.Close
objWorkbook5.Close
objWorkbook6.Close
objWorkbook7.Close
objWorkbook8.Close
objWorkbook9.Close
objWorkbook10.Close
objWorkbook11.Close
objWorkbook12.Close
objWorkbook13.Close
objWorkbook14.Close
objWorkbook15.Close
objWorkbook16.Close
objWorkbook17.Close
objWorkbook19.Close
objWorkbook20.Close
objWorkbook21.Close
objWorkbook18.Close