1 Attachment(s)
Program used to work fine,not anymore
This program used to work fine once upon a time but when i tried running it again recently it gave me an error Compile error: User defined type not defined.Anyone has any idea why this happened? Please do me a favor n try running it for me on ur pc and c whether it gives u any problem. Please put and END at the end of this program because the box doesnt close automatically when it finishes wid the purging job.I have to manually close it.Please convert it to an exe once u r done.Thank you so much! :)
Re: Program used to work fine,not anymore
Zip up your project and post it. Do you have a reference to Microsoft Scripting Runtime? That would cause an error.
Re: Program used to work fine,not anymore
harjit,
Don't use END use Unload Me
Re: Program used to work fine,not anymore
Reference Microsoft Scripting RunTime and try using this...
VB Code:
Dim fso As FileSystemObject
Set fso = New FileSystemObject
Re: Program used to work fine,not anymore
What does this mean?Reference Microsoft Scripting RunTime ? Im new to vb, so I have no idea what this means.Plz help
Re: Program used to work fine,not anymore
Quote:
Originally Posted by harjit
What does this mean?Reference Microsoft Scripting RunTime ? Im new to vb, so I have no idea what this means.Plz help
You will find it under References. It is necessary if you wish to use the File System Object.
Re: Program used to work fine,not anymore
Load your project
On top bar go
Project --> Referances
Find the microsoft Scripting runtime and tick it
Click ok and compile it :)
Re: Program used to work fine,not anymore
As soon as i thought ive completed my work thats when my codes tell me there's another problem, ive never had this problem before. It says runtime error "424" : Object Required. The line in bold is where the problem is,can someone plz figure this out for me?Thank you so much.
VB Code:
Private Sub Form_Activate()
Dim fso As New FileSystemObject
Dim RootPath As String
Dim Report As String
Dim Path As String
Dim KeepDay As Integer
Dim root As Folder
Dim Fol1 As Folder
Dim Fol2 As Folder
Dim Fol3 As Folder
Dim File1 As File
Dim File2 As File
Dim vStart As Date
Dim vEnd As Date
Dim DelNum As Long
DelNum = 0
vStart = Now
RootPath = "C:\Xfiles\WIPFS\_AccMgr\Thruput\"
Open App.Path & "\Parameter.txt" For Input As #1
Do Until (EOF(1) = True)
KeepDay = 0
Input #1, KeepDay
Loop
Close #1
Open App.Path & "\DeletedFile.txt" For Output As #2
Set root = fso.GetFolder(RootPath)
For Each Fol1 In root.SubFolders
Set Fol2 = fso.GetFolder(RootPath & Fol1.Name)
For Each File1 In Fol2.Files
If DateDiff("d", File1.DateLastModified, Date) > KeepDay Then
Print #2, RootPath & Fol1.Name & "\" & File1.Name, DateDiff("d", File1.DateLastModified, Date)
[B]lblFile.Caption = RootPath & Fol1.Name & "\" & File1.Name[/B]
fso.CopyFile RootPath & Fol1.Name & "\" & File1.Name, _
RootPath & Fol1.Name & "\Archive\" & File1.Name, True
fso.DeleteFile RootPath & Fol1.Name & "\" & File1.Name
DelNum = DelNum + 1
End If
DoEvents
Next
Next
Close #2
Open App.Path & "\ArchParameter.txt" For Input As #3
Do Until (EOF(3) = True)
KeepDay = 0
Input #3, KeepDay
Loop
Close #3
Open App.Path & "\DeletedArchFile.txt" For Output As #4
Set root = fso.GetFolder(RootPath)
For Each Fol1 In root.SubFolders
Set Fol2 = fso.GetFolder(RootPath & Fol1.Name)
For Each File1 In Fol2.Files
If DateDiff("d", File1.DateLastModified, Date) > KeepDay Then
Print #4, RootPath & Fol1.Name & "\" & File1.Name, DateDiff("d", File1.DateLastModified, Date)
lblFile.Caption = RootPath & Fol1.Name & "\" & File1.Name
fso.DeleteFile RootPath & Fol1.Name & "\Archive\" & File1.Name
DelNum = DelNum + 1
End If
DoEvents
Next
Next
Close #4
vEnd = Now
Open App.Path & "\ExecutionLog.txt" For Append As #1
Print #1, "Start: " & vStart, "End: " & vEnd, "Successfully Delete " & DelNum & " Files."
Close #1
End Sub
Re: Program used to work fine,not anymore
harjit,
You are asking us to guess with out seeing your project. Does lblFile actually exist? Do you use Option Explicit in all your forms and Modules?
Re: Program used to work fine,not anymore
Yes, lblFile actually exist, it stands for label file, this is my program, i fired it long ago, now that I want to modify my codes and I cant do it, cause the line that I showed you keeps giving me problem. Any idea?
Re: Program used to work fine,not anymore
Do you not have to set file1 before trying to find its name :confused:
Re: Program used to work fine,not anymore
File1?Meaning?I dunt really think there's a problem wid my codes coz these r the same codes I used to purge my files,all i wanna do is put an END function right below this program, cause the only drawback this prog has is it doesnt close its window once it has completed its job.But what i dunt get is the new error that keeps popping up out of nowhere, ive mentioned it earlier in my post,plz help