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 $$$$$$$$$$$$$$$$$$$$$$$$$$ |
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 $$$$$$$$$$$$$$$$$$$$$$$$$$ |
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 $$$$$$$$$$$$$$$$$$$$$$$$$$ |
All times are GMT +1. The time now is 05:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com