LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Error - file already exists.

Jim,
'-------------------
Sub createfolders()
Dim cou As Long
Dim FolderStr As String
Dim FileSys As Object

For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format$(Trim$(cou), "00#") & "_" & ActiveSheet.Cells(cou, 1).Value
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder "C:\RESERVES\" & FolderStr
Next
Set FileSys = Nothing
End Sub
'----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to move files gets an error if it already exists... [email protected] Excel Worksheet Functions 6 March 7th 07 09:46 PM
Excel PageSetup Error even when a printer Exists jo Excel Programming 1 January 11th 06 02:21 AM
Error if 'name' already exists Kevin O'Neill[_2_] Excel Programming 9 November 16th 05 06:28 PM
File Name Exists Error Trap Mike Excel Programming 2 February 21st 04 01:30 AM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM


All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"