A
Arvi Laanemets
Hi
I have a VBA script, which worked finely for about half a year. The script
opens an excel workbook on server share on every night, refreshes some ODBC
queries (from Visual FoxPro tables, one query on every sheet, no formulas in
adjacent cells, all query properties are same), waits a little, and then
closes the file. The script is here:
Option Explicit
Dim objXLApp, objXLBook, strPath, strBook
strPath = "O:\Common\PerData\"
strBook = "Personal.xls"
Set objXLBook=GetObject(strPath & strBook)
Set objXLApp = objXLBook.Parent
objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
objXLBook.Sheets("EmployeesAll").QueryTables(1).Refresh
objXLBook.Sheets("EmployeesNow").QueryTables(1).Refresh
objXLBook.Sheets("Departments").QueryTables(1).Refresh
objXLBook.Sheets("Appointments").QueryTables(1).Refresh
objXLBook.Sheets("EmplDep").QueryTables(1).Refresh
WScript.Sleep(10000)
objXLApp.DisplayAlerts=False
objXLApp.ActiveWorkbook.Save
objXLApp.DisplayAlerts=True
objXLApp.Quit
I didn't change anything in the script or Excel workbook after I created
them and set them up. Now, a couple of weeks ago, on Monday morning, the
workbook was opened in my computer and an error was reported. Event log
revealed, that the error happened at night between Friday and Saturday. And
from then on, it repeats every morning. The script is stopped at row 14
objXLBook.Sheets("Appointments").QueryTables(1).Refresh
The error is "The remote server does not exist or is unavailable:
'Sheet(...).QueryTables'"
When I open the Excel file manually, and refresh queries there manually, all
works fine. When I then try to run the script, I get the error again.
When I mark the row 14 as a remark, the row 15 returns the same error. When
I mark row 15 off too, the row 17 returns the error "The remote server
machine does not exist or is unavailable: 'DisplayAlerts'", etc. It looks
like objects objXLApp and objXLBook are lost from some point.
Thanks in advance for anyone who can help me with this problem.
I have a VBA script, which worked finely for about half a year. The script
opens an excel workbook on server share on every night, refreshes some ODBC
queries (from Visual FoxPro tables, one query on every sheet, no formulas in
adjacent cells, all query properties are same), waits a little, and then
closes the file. The script is here:
Option Explicit
Dim objXLApp, objXLBook, strPath, strBook
strPath = "O:\Common\PerData\"
strBook = "Personal.xls"
Set objXLBook=GetObject(strPath & strBook)
Set objXLApp = objXLBook.Parent
objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
objXLBook.Sheets("EmployeesAll").QueryTables(1).Refresh
objXLBook.Sheets("EmployeesNow").QueryTables(1).Refresh
objXLBook.Sheets("Departments").QueryTables(1).Refresh
objXLBook.Sheets("Appointments").QueryTables(1).Refresh
objXLBook.Sheets("EmplDep").QueryTables(1).Refresh
WScript.Sleep(10000)
objXLApp.DisplayAlerts=False
objXLApp.ActiveWorkbook.Save
objXLApp.DisplayAlerts=True
objXLApp.Quit
I didn't change anything in the script or Excel workbook after I created
them and set them up. Now, a couple of weeks ago, on Monday morning, the
workbook was opened in my computer and an error was reported. Event log
revealed, that the error happened at night between Friday and Saturday. And
from then on, it repeats every morning. The script is stopped at row 14
objXLBook.Sheets("Appointments").QueryTables(1).Refresh
The error is "The remote server does not exist or is unavailable:
'Sheet(...).QueryTables'"
When I open the Excel file manually, and refresh queries there manually, all
works fine. When I then try to run the script, I get the error again.
When I mark the row 14 as a remark, the row 15 returns the same error. When
I mark row 15 off too, the row 17 returns the error "The remote server
machine does not exist or is unavailable: 'DisplayAlerts'", etc. It looks
like objects objXLApp and objXLBook are lost from some point.
Thanks in advance for anyone who can help me with this problem.