Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default 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/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default create new Folder

thanks for all help...

Regards
dalla

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

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 Folder Using VBA DoooWhat Excel Discussion (Misc queries) 5 September 21st 07 10:28 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM
Create a Folder Murray Outtrim[_3_] Excel Programming 1 March 2nd 04 06:41 PM
Create Folder Murray Outtrim[_4_] Excel Programming 1 March 2nd 04 06:12 PM
Create Folder / Copy Folder / Replace Murray Outtrim[_2_] Excel Programming 0 February 24th 04 06:40 PM


All times are GMT +1. The time now is 09:15 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"