Hi Scott. There is not a concise way to do this in Excel. The following uses two instances of Excel. One instance runs a workbook that watches your folder. (The folder that will recieve the files from the CNC machine). This workbook sends notification to the visible workbook that displays the updates you are wishing for.
I am assuming that the only files within a single folder will be those created by the CNC machine. If there are other files, we will need to adjust for that.
See the attached zip file that contains two workbooks created by following the instructions below.
Create a workbook named "CNCCycleWatcherHelper.xls", Add a standard module and place this code within:
Save and close this file.
Create another workbook named "CNCCycleWatcher.xls". Add this code into the workbook class:
Add a standard module and place this code within:
There are three mandatory and one optional arguments passed to a procedure named "StartWatch" located in "CNCCycleWatcherHelper.xls". How you assign value to these args is up to you. In this example and the attached zip file, I created some variables to make it plain and stored the values in cells to make it easy.
The full path to "CNCCycleWatcherHelper.xls"
WatcherHelperFullName = ActiveSheet.Range("A14").Text
The full path of the folder we are watching.
WatchThisFolder = ActiveSheet.Range("A12").Text
The interval to check for updates. This is an optional argument with a default of 500 milliseconds.
PollingInterval = ActiveSheet.Range("A16").Value
The other mandatory object is a reference to the workbook itself. This reference will not need editing.
The names of the workbooks are not essential, but the first two arguments above are essential.
The code in the hidden instance should actually be packed into an activeX.exe. If you have any VB coders on site, they should have no problem placing the code into VB with minimal editing. This would allow you to use events which are more dependable than application.run.
Download the attached for guidance.
Let me know if you have any problems...
Bookmarks