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

objFSO.FileCopy error copying a file

Status
Not open for further replies.

802IS

IS-IT--Management
Aug 12, 2008
6
US
I'm trying to copy a file from one location to another and I'm getting object doesn't support this property or method: 'objFSO.FileCopy' error. What am I doing wrong with the code below and how can I correct it?


Code:
' objects needed to aquire username
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set UserName = GetObject("LDAP://" & objUser.UserName)

strDirDes = "C:\Documents and Settings\" & objNetwork.UserName & "\Application Data\Microsoft\Templates" 
strDir = "\\chcb6\install$\templates" 

'array that contains the file names
arrFileName = array("\CHCB Letterhead.doc", "\CHCB Memo Template.doc", "\CHCB Policy & Procedure Template.doc", _ 
"\CHCB Admin FAX Template.doc", "\CHCB Clinical FAX Template.doc")

Set objFSO = CreateObject("Scripting.FileSystemObject")

for each name in arrFileName
	If objFSO.FileExists(StrDirDes & name) Then	
	    Wscript.Echo "File does exist."
	Else
			 'Wscript.Echo strDir & name
		     objFSO.FileCopy strDir & name , strDirDes & name
	End If
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top