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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error "Object required" when using method "Folder.NewFolder"

Status
Not open for further replies.

teklan

Programmer
Dec 29, 2010
4
DE
My intention is to create a new folder via the VBScript method "Folder.NewFolder". However, when running the script below on Windows XP I get the error "800A01A8 - Object required" that refers to the highlighted line.

Code:
@Prerequisite: .vbs-script is placed in a directory that contains a folder "parentFolder"
@Expected execution result: A folder "childFolder" is created in the folder "parentFolder"
Dim objShell, objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("parentFolder")
[green]objFolder.NewFolder("childFolder")[/green]

I'm aware that there is also the possibility to create a new folder with the help of the method "CreateFolder" of the "Scripting.FileSystemObject". Still, I'd like to know why the script above does not work for me on Windows XP. I haven't checked the version of my shell dll yet (e.g. via "DllGetVersion") but I assume that it's gonna be the right one as I use XP that should have shell dll version 6.0. The MSDN documentation says that the method "Folder.NewFolder" requires shell dll version 4.71 or later. Basically, the code itself ought to be correct as when running the script above on Windows Server 2008 everything is fine for me.

Thanks for any help.
 
>shell dll version 4.71

Essentially NT4 with IE4, or Windows 98 or later, so that should be fine ...

The line that is failing is actuakllyy

Set objFolder = objShell.Namespace("parentFolder")


"parentFolder" needs to be a fully-qualified path to the folder in question, not just a folder name (well, it can also be one of the special folder constants, but that is clearly not what you are going for here). If you just stick a folder name in then the NameSapce method returns Nothing, which then causes the NewFolder call to fail.
 
Thanks, now it works.

But why does it somehow seem to work as well with non-fully-qualified paths on my Windows Server 2008? And where do I get to read the information about the fully-qualified path for the NewFolder-method myself? There is nothing about that issue on this website.
 
That link specifically states:

"a string that specifies the path of the folder"

which is just another way of describing a fully-qualified path
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top