Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Windows Message when Directory Already Exist

I have a macro that creates a directory (see below). However, I would like to
have a statement to tell me the following:
1.- Find if directory already exist.
2.- Have a window message to give me the option €œYES€ or €œNO€ to rewrite it.
3.- If I click €œYES€ I will rewrite it.
4.- If I click €œNO€ I will came back to retype the information.

Thanks in advance.
Maperalia.

'$$$$ START CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$
NewDir = Format(Sheets("Test").Range("D5").Value)
MkDir "C:\Mario\Radius and Flat Bend\ColorLINE\Radial\ColorLine Template\" &
_ Format(Sheets("Test").Range("D5").Value)
'$$$$ END CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Windows Message when Directory Already Exist

I'm not sure what you mean in steps 3 and 4, but you can try something
like

Sub AAA()
Dim DirName As String
Dim Res As VbMsgBoxResult
DirName = "C:\Test\Test2"
If Dir(DirName, vbDirectory) = vbNullString Then
' directory does not exist
Res = MsgBox("Rewrite?", vbYesNo)
If Res = vbYes Then
' user clicked Yes
Else
' user clicked No
End If
Else
' directory exists
End If
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Mon, 5 Jan 2009 13:23:02 -0800, Maperalia
wrote:

I have a macro that creates a directory (see below). However, I would like to
have a statement to tell me the following:
1.- Find if directory already exist.
2.- Have a window message to give me the option “YES” or “NO” to rewrite it.
3.- If I click “YES” I will rewrite it.
4.- If I click “NO” I will came back to retype the information.

Thanks in advance.
Maperalia.

'$$$$ START CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$
NewDir = Format(Sheets("Test").Range("D5").Value)
MkDir "C:\Mario\Radius and Flat Bend\ColorLINE\Radial\ColorLine Template\" &
_ Format(Sheets("Test").Range("D5").Value)
'$$$$ END CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Windows Message when Directory Already Exist

Chip;
Thanks for your quick response.
I placed your code before and after my statement and it is not working. I
believe that I am putting my statement in the wrong location. Base in the
statement I gave you (see below). Could you please tell me where I should
place your code to make it work.

Kind regards.
Maperalia.



'$$$$ START CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$
Dim DirName As String
Dim Res As VbMsgBoxResult
DirName = "C:\Test\Test2"
If Dir(DirName, vbDirectory) = vbNullString Then
' directory does not exist
Res = MsgBox("Rewrite?", vbYesNo)
If Res = vbYes Then
' user clicked Yes
Else
' user clicked No
End If
Else
' directory exists
End If

NewDir = Format(Sheets("Test").Range("D5").Value)
MkDir "C:\Test\Test2

'$$$$ END CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$




"Chip Pearson" wrote:

I'm not sure what you mean in steps 3 and 4, but you can try something
like

Sub AAA()
Dim DirName As String
Dim Res As VbMsgBoxResult
DirName = "C:\Test\Test2"
If Dir(DirName, vbDirectory) = vbNullString Then
' directory does not exist
Res = MsgBox("Rewrite?", vbYesNo)
If Res = vbYes Then
' user clicked Yes
Else
' user clicked No
End If
Else
' directory exists
End If
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Mon, 5 Jan 2009 13:23:02 -0800, Maperalia
wrote:

I have a macro that creates a directory (see below). However, I would like to
have a statement to tell me the following:
1.- Find if directory already exist.
2.- Have a window message to give me the option €œYES€ or €œNO€ to rewrite it.
3.- If I click €œYES€ I will rewrite it.
4.- If I click €œNO€ I will came back to retype the information.

Thanks in advance.
Maperalia.

'$$$$ START CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$
NewDir = Format(Sheets("Test").Range("D5").Value)
MkDir "C:\Mario\Radius and Flat Bend\ColorLINE\Radial\ColorLine Template\" &
_ Format(Sheets("Test").Range("D5").Value)
'$$$$ END CREATE NEW DIRECTORY $$$$$$$$$$$$$$$$$$$$$$$$$$



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
Check if a predefined number of workbooks exist in a specific directory Ixtreme Excel Programming 4 January 2nd 07 04:35 PM
Check if a pre0defined number of workbooks exist in a specific directory Ixtreme Excel Programming 1 January 2nd 07 01:57 PM
Data may exist in the sheet(s) message cedtech23[_17_] Excel Programming 5 July 21st 06 03:12 PM
Save to directory and create if not exist Rob Excel Programming 8 January 29th 05 05:39 PM
How to check if a folder/directory exist using VBA wellie Excel Programming 1 March 1st 04 02:24 AM


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"