Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
Is there a way to create the folder if the suggested path
does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
Try this
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 "M. Barnes" wrote in message ... Is there a way to create the folder if the suggested path does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
Hi M,
The following will create the new folder if it does not exist and will not complain if it does : On Error Resume Next MkDir "C:\MyNewFolder" On Error GoTo 0 --- Regards, Norman "M. Barnes" wrote in message ... Is there a way to create the folder if the suggested path does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
This is okay, but I want user input to confirm the new
directory name. -----Original Message----- Try this 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 "M. Barnes" wrote in message ... Is there a way to create the folder if the suggested path does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
Try this
Sub MakeDirectory2() Dim Dirname As String Dim Answer As String Dim fs As Object Set fs = CreateObject("Scripting.FileSystemObject") Dirname = "C:\MyDir" If Not fs.FolderExists(Dirname) Then Answer = MsgBox("Do you want to create a folder", vbOKCancel) If Answer = vbOK Then fs.CreateFolder Dirname Else 'nothing End If Else ' do nothing End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "MB" wrote in message ... This is okay, but I want user input to confirm the new directory name. -----Original Message----- Try this 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 "M. Barnes" wrote in message ... Is there a way to create the folder if the suggested path does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Method
Just a heads up:
This will fail unless the lowest folder is the only one missing. You might want to add code to protect for that. -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... Try this Sub MakeDirectory2() Dim Dirname As String Dim Answer As String Dim fs As Object Set fs = CreateObject("Scripting.FileSystemObject") Dirname = "C:\MyDir" If Not fs.FolderExists(Dirname) Then Answer = MsgBox("Do you want to create a folder", vbOKCancel) If Answer = vbOK Then fs.CreateFolder Dirname Else 'nothing End If Else ' do nothing End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "MB" wrote in message ... This is okay, but I want user input to confirm the new directory name. -----Original Message----- Try this 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 "M. Barnes" wrote in message ... Is there a way to create the folder if the suggested path does not exist? In other words, search for the suggested folder first, if it doesn't exist, the system will prompt "That folder does not exist, do you wish to create it?". I've seen this happen in other programs, and desire to add it to mine. I'm currently using the GetSaveAs method, but am not sure if it is the best way. Thanks for any help you can provide. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Please post this thread a correct full method, method about | New Users to Excel | |||
Please post this thread a complete correct method, method about te | New Users to Excel | |||
Another Method or 2? | Excel Discussion (Misc queries) | |||
No Success with GetSaveAs | Excel Discussion (Misc queries) | |||
Using GetSaveAs | Excel Programming |