Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Sri
 
Posts: n/a
Default 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   Report Post  
Bob Phillips
 
Posts: n/a
Default

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
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
Create invoices from excel workbook KJH Excel Worksheet Functions 5 December 22nd 04 02:21 PM
trying to create Lost in reconcillation Excel Discussion (Misc queries) 2 December 19th 04 01:05 AM
Use Julian Date To Create Serial Number antho10359 Excel Discussion (Misc queries) 4 December 9th 04 01:50 AM
How do you create a macros without overwriting the previous one y. Gibbie Excel Discussion (Misc queries) 2 November 29th 04 10:09 PM
How do I create a formula that will multiply a 5% of a value >$150 babydear12 Excel Worksheet Functions 2 October 29th 04 01:00 AM


All times are GMT +1. The time now is 11:37 PM.

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

About Us

"It's about Microsoft Excel"