Hi,

I'm using a code which makes use of FileSystemObjects. I used to have Excel 2003, but this now switched to Excel 2010- and now the code doesn't work anymore.. For the code to work in 2003, I switched on Microsoft Scripting Runtime via Tools\References in VBA - however, this reference doesn't seem to be available in 2010 anymore. Could you help me out please? Thanks!

I copied my code below for completeness:

'Open the latest transverse views
 ' !! If the macro doesn't run: open VBA > Tools > References and activate the Microsoft Scripting Runtime !!
 
Dim FileSys As FileSystemObject 
Dim objFile As File 
Dim myFolder 
Dim strFilename As String 
Dim dteFile As Date 
 
 'set path for files - change for your folder
Const myDir As String = "Y:\Transverse Views" 
 
 'set up filesys objects
Set FileSys = New FileSystemObject 
Set myFolder = FileSys.GetFolder(myDir) 
 
 'loop through each file and get date last modified. If largest date then store Filename
dteFile = DateSerial(1900, 1, 1) 
For Each objFile In myFolder.Files 
    If Left(objFile.Name, 4) = "Tran" And objFile.DateLastModified > dteFile Then 
        dteFile = objFile.DateLastModified 
        strFilename = objFile.Name 
    End If 
Next objFile 
 
Workbooks.Open "Y:\Transverse Views\" & strFilename