create new Folder

  • Thread starter Thread starter dallas
  • Start date Start date
D

dallas

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
 
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
 
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
 
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, 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 **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top