Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If REPORT_TYPE1 = 1 Then
	    Str_Path = "D:\REPORTS\Batch_Rpt\"
	End If 
	
	If REPORT_TYPE2 = 1 Then
		Str_Path = "D:\REPORTS\Custom_Rpt\"
	End If
Set FSO = CreateObject("Scripting.FileSystemObject")

	'deleting file
	Set temp_files = FSO.GetFolder("D:\REPORTS\temp\").Files
	For Each file In temp_files
		path = file
		Kill path
	Next

' Define folder we want to list files from

	Set RPT_Folder = FSO.GetFolder(Str_Path)
	Set R_Files = RPT_Folder.Files


What I have tried:

"deleting file" part is working properly.
Posted
Updated 6-Feb-23 9:36am
v2
Comments
CHill60 6-Feb-23 9:48am    
"not working" is the least helpful thing we get told. What is happening (or not happening)
Andre Oosthuizen 6-Feb-23 9:53am    
If the "deleting file" is working fine, what is NOT working then. We cannot see your screen to determine where the error is, you need to tell us what is happening where and when.
prashant.rao11 6-Feb-23 9:55am    
"Application defined or object defined error" this error msg is showing in runtime at line "Set RPT_Folder = FSO.GetFolder(Str_Path)"
prashant.rao11 6-Feb-23 9:57am    
i think GetFolder method is not taking the path saved in object Str_Path
Richard Deeming 6-Feb-23 10:06am    
More likely that you haven't set any value in Str_Path. Try stepping through your code and examining the values in your three variables: Str_Path, REPORT_TYPE1, and REPORT_TYPE2.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900