Your error indicates you are missing a reference to SHDocVw. I am not sure what object that is, but it appears to be a COM component based on a quick Google search. I've never tried referencing one from within a script, but you can try. You'll need to add a reference to all required external assemblies to the script component before you add the method. To do that,
Select the scrip component.
In the "Properties" window, click the elipses next to the "References" property.
Locate the assemblies you wish to add as references.
It might also help if you can provide where you got the script code from as it might have some information on the references required.
The Using/Imports area lets you enter using directives for any referenced types to be used in the methods for this script. You must first add the assembly/assemblies you intend to use by completing the script's References property (in the Design Properties window). See the Script topic for details on the References property. Any referenced types must also be added to the References folder in Solution Explorer for the project. See the Using Project References topic for more information.
I also found this posting, which has the exactly code that is in your Script above: