Home |
Search |
Today's Posts |
#1
|
|||
|
|||
To create folders using VBA
Hello,
When I try to save an excel file using VBA and the folder name mentioned in the filepath is not available, then excel gives a error message..is there any way to force excel to crate the folder and the save the file accordingly.. I use FilesystemObject to create folders now...but just wanted to know if there is any other way of doing the same!! Thanks, Sri |
#2
|
|||
|
|||
Sub test()
If Not FolderExists("C:\Bob") Then MkDir "C:\Bob" End If End Sub '----------------------------------------------------------------- Function FolderExists(Folder) As Boolean '----------------------------------------------------------------- Dim sFolder As String On Error Resume Next sFolder = Dir(Folder, vbDirectory) If sFolder < "" Then If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then FolderExists = True End If End If End Function -- HTH RP (remove nothere from the email address if mailing direct) "Sri" wrote in message ... Hello, When I try to save an excel file using VBA and the folder name mentioned in the filepath is not available, then excel gives a error message..is there any way to force excel to crate the folder and the save the file accordingly.. I use FilesystemObject to create folders now...but just wanted to know if there is any other way of doing the same!! Thanks, Sri |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Create invoices from excel workbook | Excel Worksheet Functions | |||
trying to create | Excel Discussion (Misc queries) | |||
Use Julian Date To Create Serial Number | Excel Discussion (Misc queries) | |||
How do you create a macros without overwriting the previous one y. | Excel Discussion (Misc queries) | |||
How do I create a formula that will multiply a 5% of a value >$150 | Excel Worksheet Functions |