Ok… Now I will try to explain clearly my problem I confront with. As I have understood, this problem doesn’t have any attitude to QueryTables object and has an attitude to Excels security, but for all that the QueryTables object becomes a sticking point. Following my thout… By now temporally forget about Workbook_Open() function, but let’s agree that one workbook WB_1.xls has macro SUB_1(), that uses QueryTables object for it’s performance. Let’s view two cases:
1) We open WB_1.xls and press Alt+F8. We select a macro in appeared window and press button Run. By the script of these actions from the side of user (i.e. myself), macro is performed successfully (silently) and retrieves data from DB.
2) We write WSH the following script:
var objXL = WScript.CreateObject("Excel.Application");
objXL.Visible = true;
objXL.Workbooks.Open(path + " WB_1.xls");
var xxx = objXL.Run("WB_1.xls!SUB_1()");
objXL.Quit();
After the script is launched Excel is run and begins the performing macro SUB_1().When macro’s performing reaches the line «.Refresh BackgroundQuery:=False» (retrieve’s performing data from DB), Excel immediately outs ODBC connections list window with the request to chose appropriate ODBC-connection.
We have the following question: What should we do to make Excel silently perform macro SUB_1() in the second case do the same in the first case??