Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I was trying to delete a file using QV macro vbscript but it showing me some error on creating object.
sub deletefile()
dim filesys, sdir
Set filesys = CreateObject("Scripting.FileSystemObject")
sdir = filesys.GetParentFolderName(wscript.ScriptFullName)
If filesys.FileExists(sdir & "\test.docx") Then
filesys.DeleteFile sdir & "\test.docx"
Response.Write("File deleted")
End If
end sub
ActiveX component can't create object: 'Scripting.FileSystemObject'
Regards,
Shumail Hussain
Hi,
Did you try changing security from 'Safe Mode' to 'System Access' in edit module?
Thanks
Amit
Hi Amit,
After changing my security from Safe Mode to System Access i am getting error on line 3
Object required: 'wscript'
Regards,
Shumail Hussain
Try this:
sub deletefile()
dim filesys, sdir
Set filesys = CreateObject("Scripting.FileSystemObject")
set wscript = CreateObject("WScript.Shell")
sdir = filesys.GetParentFolderName("wscript.ScriptFullName")
If filesys.FileExists(sdir & "\test.docx") Then
filesys.DeleteFile sdir & "\test.docx"
Response.Write("File deleted")
End If
end sub