Sunday, March 25, 2012

ActiveX

I have to put some ActiveX code in the first step of a DTS package, which will search thru all the files in some folder and if it finds a file with filename starting with "Test" (like TestFile.txt), the script will rename it and then use it for transforming data to SQL tables.

In VB Dir$ function could have been used, what should I use in ActiveX?

Thanks a lot for your helpI'm not sure how to rename the file but you might be able to use the xp_fileexist extended proc to see if the file is in the directory.|||This is a start:

Function Main()

Dim objFSO
Dim objFolder
Dim objFile
Dim fileName
Dim folderName

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("\\server\share$\dir\")
folderName = "\\server\share$\dir\Archive\" & Month(Now) & Day(Now) & Year(Now) & "_" & Hour(Now) & Minute(Now) & Second(Now) & "\"

For Each objFile in objFolder.Files

objFSO.CreateFolder(folderName)

fileName = objFile.Path

objFSO.MoveFile fileName, folderName
Next

Main = DTSTaskExecResult_Success

End Function|||Now I'm getting what I need to do, thanks a lot for your help.sql

No comments:

Post a Comment