ActiveX script to get a dynamic filename?

  • I am looking to use activeX to be able to take a file that is placed in a folder were the name will be dynamic.

    When I am able to get the file name I will then be able to manipulate the file (code which I already have inplace). I am at a loss as to a good way to get the filename when it is not known in a folder.

    This folder will only have one file in it at a time. Once the file is finished processing it will be deleted out of the temp directory.

    Any clues I would appreciate it.

    Thanks,

    Leeland

  • I use something that might be helpful.  I set up a DTS that checks every day on an FTP site for a file name that is dynamic in that the date is part of the name.  Changes every morning at 0200 and my job looks for it at 0400 based on that days date.  If found it pulls it in processes it and puts it back on the FTP site with data added from my db for further processing down the line.  Sound helpful?

  • Well I got around the problem with the following ActiveX Script...it looks for the newest filename in a directory.  In my case I am only going to have one file in the directory so it doens't really matter...once it gets the file name it hands it off to another activeX script that moves it and changes the name.

     

    '**********************************************************************

    '  Visual Basic ActiveX Script

    '************************************************************************

    Function Main()

     FindNewestFile

     Main = DTSTaskExecResult_Success

    End Function

    function FindNewestFile()

    '--------------------------------

    'Variable Declaration

    '--------------------------------

    Dim fsFile

    Dim sDocumentCnt

    Dim sPrevDate

    Dim sNewestFileName

      

    Dim objFS

     Set objFS = CreateObject("Scripting.FileSystemObject")

    Dim Path

     Path = "c:\File_In_Temp\"

    Dim fsFolder

     Set fsFolder = objFS.GetFolder(path)

    Dim fsFiles

     Set fsFiles = fsFolder.Files

    '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    'LOOP THROUGH ALL FILES IN THE PATH DIRECTORY TO FIND THE NEWEST FILE SHOULD ONLY BE ONE FILE

    'IN THE DIRECTORY AT A TIME.  ONCE THE NEWEST FILE IS FOUND SET THE NAME EQUAL TO THE GLOBAL VARIABLE

    '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     FOR EACH fsFile in fsFiles

      if sPrevDate<fsFile.DateCreated then

       sPrevDate=fsfile.DateCreated

      DTSGlobalVariables("@FileName").Value = fsfile.name

      end if

     next

    '--------------------------------

    'Used in Testing

    '--------------------------------

    'MsgBox "File Name: " & ( DTSGlobalVariables("@FileName").Value )

    end function

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply