Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help with ActiveX script

Author  Topic 

dwalker79
Yak Posting Veteran

54 Posts

Posted - 2009-08-19 : 11:29:08
I need to convert this ActiveX script to Visual Basic 2008 for SSIS. Can someone PLEASE tell me if there is an easy way to do this?

Thanks!
Dustin

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()

Dim filesys, file, folder, filelist, filetxt, filename, sfile, lastdate, moddate
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set filesys = CreateObject("Scripting.FileSystemObject")

'get last date processed
Set filetxt = filesys.OpenTextFile("\\it101v\dmufiles\dealer master files\gm\last_process_date.txt", ForReading, False)
lastdate = CDate(filetxt.ReadAll)
filetxt.Close

REM MsgBox (lastdate)

Set folder = filesys.GetFolder("\\it101v\dmufiles\dealer master files\gm")
Set filelist = folder.Files

'USA
For Each file in filelist
if left(file.Name,20) = CStr("RIM_DLR_ELIG_FULL_US") and file.DateLastModified > lastdate and file.Type = "DAT File" then
filename = "\\it101v\dmufiles\dealer master files\gm\" & file.Name
moddate = file.DateLastModified
end if
next
'MsgBox(filename)

if filesys.FileExists(filename) then
' filesys.CopyFile filename,"\\corp-file-003\itcommon\dba\scripts\RIM_DLR_ELIG_FULL_US.DAT","true"
filesys.CopyFile filename,"\\corp-it-001\esqldata\RIM_DLR_ELIG_FULL_US.DAT","true"
'update last date processed
Set filetxt = filesys.OpenTextFile("\\it101v\dmufiles\dealer master files\gm\last_process_date.txt", ForWriting, False)
filetxt.Write moddate
filetxt.close
'msgbox ("us copied")
else
Err.Raise 1, "No US file"
end if

filename = ""

'Canada
For Each file in filelist
if left(file.Name,20) = CStr("RIM_DLR_ELIG_FULL_CA") and file.DateLastModified > lastdate and file.Type = "DAT File" then
filename = "\\it101v\dmufiles\dealer master files\gm\" & file.Name
rem msgbox (file.name)
end if
next

if filesys.FileExists(filename) then
filesys.CopyFile filename,"\\it100vsql\esqldata\RIM_DLR_ELIG_FULL_CA.DAT","true"
rem msgbox ("can copied")
else
Err.Raise 1,"No Canada file"
end if

Main = DTSTaskExecResult_Success
End Function
   

- Advertisement -