How to automatically process image files copied to a Windows folder
The following 2 macros allow monitoring a specified folder and automatically load any TIFF file copied to it for processing. Run the StartMonitoring macro to activate the process.
Imports System.IO Public Module Macros ' The Windows object used to monitor the file system ' Private WithEvents _fileSystemWatcher As System.IO.FileSystemWatcher ' The path of a folder to monitor ' Private Const cIncomingFolder As String = "D:\Incoming" ' Run this macro to start monitoring cIncomingFolder ' Sub StartMonitoring _fileSystemWatcher = New FileSystemWatcher _fileSystemWatcher.Path = cIncomingFolder _fileSystemWatcher.Filter = "*.tif" _fileSystemWatcher.SynchronizingObject = ThisApplication.MainForm _fileSystemWatcher.EnableRaisingEvents=True End Sub Private Sub _fileSystemWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles _fileSystemWatcher.Created ' Wait for the file to be copied ' While True Try Dim fs As New FileStream(e.FullPath,FileMode.Open,FileAccess.ReadWrite) fs.Close Exit While Catch ex As System.Exception End Try End While ' Load the file in the application for processing ' Dim docList1 With Application.DocumentCommands.Open(Nothing) .Filenames = New String() {e.FullPath} .Run(docList1) End With End Sub End Module
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions