Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with an ActiveX in a DTS package!

Status
Not open for further replies.

jsql12

Technical User
Mar 27, 2007
28
US
Hi all,

I'm creating a DTS Package that only has a one step, which is an activeX script. It is supposed to remove any files with a .BKP extension. The script is as follows:

call CleanFile("\\Server\F$\SQL_Backup\")

sub CleanFile(folderspec)
Dim fso
Dim oFolder
Dim oFile
Dim f1

set fso = CreateObject("Scripting.FileSystemObject")
set oFolder = fso.GetFolder(folderspec)
set oFile = oFolder.Files

For each f1 in oFile
IF Right(f1.Name,3) = "BKP" then
fso.DeleteFile(folderspec + f1.Name)
END IF
next

set oFolder = Nothing
set fso = Nothing
End sub

When I run the activeX script it shows failure and it returns an error: "Function NOT Found" but it still deleted the files with .BKP extension.

Does anybody know what I'm doing wrong here?

Any help is greatly appreciated.

 
I don't know if this will help or not, but here's the code that usually works for me.

Code:
Dim fso, oFile, oFolder, oFiles, fldrItem

set fso = CreateObject("Scripting.FileSystemObject")

set oFolder = fso.GetFolder(folderspec)
For Each fldrItem in oFolder.SubFolders
	Set oFiles = fldrItem.Files
	For Each oFile in oFiles
	        If Right(oFile.Name, 3) = "BKP" Then
			oFile.Delete
	        End If
	Next
Next

Set oFile = Nothing
set oFiles = Nothing
Set oFolder = Nothing
Set fso = Nothing

I tried to modify it to make it more generic. Hopefully I didn't mess it up in the process. :)
 
Thanks fuzzyocelot! but I still get the same error.
 
Can you post your entire ActiveX Script?

Ignorance of certain subjects is a great part of wisdom
 
If you still get the "function not found" error, then I'm wondering if you're missing the DLL for "Scripting.FileSystemObject". Check to see if Scrrun.dll is on your computer.

If you have the DLL, maybe you can try putting in a MsgBox somewhere as a "breakpoint" of sorts to see where it's having a problem at. I'm wondering if it doesn't like the Call function you're using.
 
I tested it out with your original code, and I think you're close. It needs to be called from the Main() function.

Try doing the following:

Code:
Function Main()
	call CleanFile("\\Server\F$\SQL_Backup\")
	Main = DTSTaskExecResult_Success
End Function
 
Thanks a lot fuzzyocelot that was exactly the mising part. I really appreciate it.

jsql12
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top