Indarnav
asked on
Invalid procedure call or argument
below vbs code giving "Invalid procedure call or argument" error at line 93. pls guide.
'basic declarations
Const BIF_returnonlyfsdirs = &H0001
Const BIF_dontgobelowdomain = &H0002
Const BIF_statustext = &H0004
Const BIF_returnfsancestors = &H0008
Const BIF_editbox = &H0010
Const BIF_validate = &H0020
Const BIF_browseforcomputer = &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludesSourcePaths = &H4000
Dim drv,ssp,CDDrive,sDestinationPath, objFile
Dim fso, fld,homefolder
setfol()
Sub setfol()
strComputer="."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive",,48)
For Each objItem In colItems
colDrives = colDrives & "" & Replace(UCase(objItem.Drive), ":", "")
Next
MsgBox ("Your CD/DVD Drive letter is ")& colDrives & " " & "," & " " &("Please type it."),vbInformation,"CD/DVD Drive Letter"
Valid=False
Do
strDrive = InputBox("Please Type Drive Letter for CD/DVD as displayed", "Select CD/DVD Drive", Strdrive)
If Instr(colDrives, UCase(strDrive)) > 0 Then Valid=True
If Trim(strdrive) = "" Then WScript.Quit
Loop Until Valid=True
MsgBox "Thanks for Typing Correct Alphabet " & strDrive,vbInformation,"Correct Drive"
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
homefolder = sDestinationPath
ssp = Strdrive & ":\data" '(\*.* to copy all)
'calling folder selection function
setdesti()
'remove read only tag from destination folder.
NotReadOnly(HomeFolder)
'select destination folder
'copying code
Ofso.CopyFolder ssp,sDestinationPath,True
Set fso = Nothing
End Sub
'2: selection for destination folder
sub setdesti()
sDestinationPath = BrowseForFolder( _
"Select a sDestinationPath or folder to copy", _
BIF_returnonlyfsdirs , _
"")
end sub
'3:browse folder function
Function BrowseForFolder(title, flag, dir)
On Error Resume Next
Dim oShell, oItem, tmp
' Create WshShell object.
Set oShell = WScript.CreateObject("Shell.Application")
' Invoke Browse For Folder dialog box.
Set oItem = oShell.BrowseForFolder(&H0, "Select Destination Folder/Folder ", flag, dir)
' Now we try to retrieve the full path.
BrowseForFolder = oItem.ParentFolder.ParseName(oItem.Title).Path
Set oShell = Nothing
Set oItem = Nothing
On Error GoTo 0
End Function
'5: code for folder name
Sub NotReadOnly(FolderName)
Dim fld, fil, sf
Set fld = fso.GetFolder(FolderName)
For Each fil In fld.Files
fil.Attributes = 0
Next
For Each sf In fld.SubFolders
NotReadOnly sf.Path
Next
Set fil = Nothing
Set sf = Nothing
Set fld = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't know. Did you try my suggestion? Programming is all about trying different things to find out as much as you can about a problem.
ASKER
i removed that function, as it is not required. it is working fine now. thanks for giving clue
ASKER