TheGreenGentleman Posted March 10, 2015 Share Posted March 10, 2015 Hi Guys, I'm trying to move away from Task Scheduler as my trigger for opening an Excel file. The problem there is it has a minimum of 5 min interval (I need at least 30 sec) and If the process of the initial instance of the Excel file is longer than the usual that after 5 min another instance executes it messes up my memory bandwidth. What I want is to use VB Script that first check if a particular Excel file is open if yes then wait for another 30 sec to check.Question: What is the right syntax/code for detecting a specific Excel file and loops every 30 sec. But I also want to be able to end the loop if I want to.Here is my current code: Gateway TimeoutRequestURI=http://timeentry/Set Recordset = CreateObject("ADODB.Recordset") ConnString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=PHMNWWKS027604; DATABASE=db_skusetup; " &_"UID=root;PASSWORD=; OPTION=3"'Check for Export Query'Recordset.ActiveConnection = ConnString exportSQL = "SELECT * FROM tb_queue_export WHERE request_status = 'Pending' ORDER BY request_id DESC LIMIT 1"Recordset.Open exportSQLSet objExcelExtract = CreateObject("Excel.Application")Set objWorkbookExtract = objExcelExtract.Workbooks.Open("C:Usersushuam00DesktopLAPTOP.xlsx") If objWorkbookExtract.ReadOnly then if Recordset.Fields(3) <> "" then end if end iftest= MsgBox(Recordset.Fields(3),3,Recordset.EOF)Recordset.Close ReadOnly is not doing it for me. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2015 Share Posted March 11, 2015 It looks like there is a discussion here:https://social.technet.microsoft.com/Forums/en-US/436f3c51-b05d-41b5-91da-066b54fdfee2/check-if-the-file-is-open-using-vb-script?forum=ITCGIt looks like you can use the WScript.Sleep method to tell your script to sleep for a certain number of milliseconds. Link to comment Share on other sites More sharing options...
TheGreenGentleman Posted March 11, 2015 Author Share Posted March 11, 2015 (edited) Checking now. Thanks for the link Edited March 11, 2015 by TheGreenGentleman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now