View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Error - file already exists.

Jim,
The other Jim has fixed the code, but do you really need to create an
instance of the FSO just to make a folder.
You do have the native MkDir.

NickHK

"Jim15" wrote in
message ...

I have the letters A - O in rows 1 - 15 of column A on my Excel
spreadsheet. However, instead of the following routine making
subfolders under C:\RESERVES I get the error "file already exists".
Can someone help?

Thanks,

Jim


Sub createfolders()
'
' CreateFolders Macro
' Macro recorded 3/22/2006 by JBW
'
Dim cou As Integer, FolderStr As String, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder "C:\RESERVES"
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:

http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=527191