Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
Another Method or 2? JMay Excel Discussion (Misc queries) 9 February 9th 07 08:11 PM
No Success with GetSaveAs D.Parker Excel Discussion (Misc queries) 5 April 20th 05 02:16 PM
Using GetSaveAs Ron McCormick[_3_] Excel Programming 1 December 17th 03 06:22 PM


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

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"