ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   create new Folder (https://www.excelbanter.com/excel-programming/300526-create-new-folder.html)

dallas

create new Folder
 
I create new Folder.

Private Sub Workbook_Open()
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End Sub


but next time Workbook_Open if Folder "C:\Spelade" exist
I want to Exit Sub

How?

Private Sub Workbook_Open()

If ####Folder "C:\Spelade" exist####
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End If
End Sub



/dalla

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

create new Folder
 
Try this dallas

Sub MakeDirectory()
Dim Dirname As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dirname = "C:\MyDir"
If Not fs.FolderExists(Dirname) Then
fs.CreateFolder Dirname
Else
' do nothing
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"dallas " wrote in message ...
I create new Folder.

Private Sub Workbook_Open()
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End Sub


but next time Workbook_Open if Folder "C:\Spelade" exist
I want to Exit Sub

How?

Private Sub Workbook_Open()

If ####Folder "C:\Spelade" exist####
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolde
End If
End Sub



/dallas


---
Message posted from http://www.ExcelForum.com/




Chip Pearson

create new Folder
 
Dallas,

Try something like

If Dir("C:\Spelade", vbDirectory) = "" Then
Debug.Print "does not exist"
Else
Debug.Print "exists"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dallas " wrote in
message ...
I create new Folder.

Private Sub Workbook_Open()
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End Sub


but next time Workbook_Open if Folder "C:\Spelade" exist
I want to Exit Sub

How?

Private Sub Workbook_Open()

If ####Folder "C:\Spelade" exist####
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End If
End Sub



/dallas


---
Message posted from http://www.ExcelForum.com/




Bob Phillips[_6_]

create new Folder
 
Private Sub Workbook_Open()

If Dir("C:\Spelade" ,vbDirectory) < "" Then
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"
MkDir strMyFolder
End If
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dallas " wrote in message
...
I create new Folder.

Private Sub Workbook_Open()
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End Sub


but next time Workbook_Open if Folder "C:\Spelade" exist
I want to Exit Sub

How?

Private Sub Workbook_Open()

If ####Folder "C:\Spelade" exist####
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End If
End Sub



/dallas


---
Message posted from http://www.ExcelForum.com/




Paul B[_6_]

create new Folder
 
Dallas, how about something like this

Private Sub Workbook_Open()
If Dir("c:\Spelade", vbDirectory) = vbNullString Then _
MkDir "c:\Spelade"
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"dallas " wrote in message
...
I create new Folder.

Private Sub Workbook_Open()
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End Sub


but next time Workbook_Open if Folder "C:\Spelade" exist
I want to Exit Sub

How?

Private Sub Workbook_Open()

If ####Folder "C:\Spelade" exist####
Exit Sub
Else
Dim strMyFolder As String

strMyFolder = "C:\Spelade"

MkDir strMyFolder
End If
End Sub



/dallas


---
Message posted from http://www.ExcelForum.com/




dallas

create new Folder
 
thanks for all help...

Regards
dalla

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com