Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Object Required: 'Wscript'

$
0
0

I've used the below VB script in my .hta application for selecting the folder. But when there is no folder is selected and I click 'Cancel' button then am getting Script error: Object Required: 'Wscript'.

Sub ButtOutFolder

  Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0

Set objShell      = CreateObject("Shell.Application")
Set objFolder     = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self

        strPath = objFolderItem.Path

Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", OPTIONS, strPath)

If objFolder Is Nothing Then
Wscript.Quit
End If

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

        OUTFOLDERPATH = objPath
        OutpathTxt.value = OUTFOLDERPATH
       
End Sub


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>