I'm trying to rename the output of my file when I unzip. I have tried renameing to test.xls
But it throws a object variable not set error. Is there another way other then scanning .datecreated
on all the files in the folder? If there is a way to rename the file on unzip that would be best.
Set oApp = CreateObject("Shell.Application")
oApp.NameSpace("C:\Users\**\Downloads\TempFolder\test.xls").CopyHere oApp.NameSpace("C:\Users\**\Downloads\TempFolder\testzip.zip").Items
Set oApp = Nothing
The
CopyHere
method is only valid for folder objects (this includes zip files when zipping), not for regular files. Hence the error message.See MSDN or here .
I would extract the zip to a folder that is guaranteed to be empty.
Then move the (single) file to your actual target folder, renaming it in the process.