Consulting

Results 1 to 3 of 3

Thread: FileSystemObject / Microsoft Scripting Runtime in Excel 2010 VBA

  1. #1

    FileSystemObject / Microsoft Scripting Runtime in Excel 2010 VBA

    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

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    739
    Location
    You may have to hunt it down manually (by using BROWSE), the actual DLL is call SCRRUN.DLL. I would do a search on that file then navigate to that directory, with my system it is located in "C:\Windows\SysWOW64\"

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,592
    Location
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •