Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mk Dir
Hello All,
I am putting the finishing touches on my system and thought of having my Excel file automatically make the necessary folder on another users computer if it does not exist. This will allow them to make their report files using templates associated with command buttons they press at time of need. Currently I tried this in my Auto_Open module 'Dim Path As String 'Path = "C:\My Documents\Temp Me" 'If IsNot Path = Dir("C:\My Documents\Temp Me") Then MkDir ("C:\My Documents\Temp Me") 'Else 'Do nothing 'End If This makes the new folder but the next time it runs create and error. Obviously because it already is in place......LOL on me. What would be the correct Dim, and If statements I am looking for to make a directory that if is there "Do Nothing" else "Make It"? May have application flavor eh? Thanks for your help -- George G |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mk Dir
Sub Auto_Open()
On Error Resume Next MkDir "C:\My Documents" MkDir "C:\My Documents\Temp Me" On Error GoTo 0 End Sub -- Regards, Tom Ogilvy "Sgwapt" wrote in message ... Hello All, I am putting the finishing touches on my system and thought of having my Excel file automatically make the necessary folder on another users computer if it does not exist. This will allow them to make their report files using templates associated with command buttons they press at time of need. Currently I tried this in my Auto_Open module 'Dim Path As String 'Path = "C:\My Documents\Temp Me" 'If IsNot Path = Dir("C:\My Documents\Temp Me") Then MkDir ("C:\My Documents\Temp Me") 'Else 'Do nothing 'End If This makes the new folder but the next time it runs create and error. Obviously because it already is in place......LOL on me. What would be the correct Dim, and If statements I am looking for to make a directory that if is there "Do Nothing" else "Make It"? May have application flavor eh? Thanks for your help -- George G |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mk Dir
Thanks Tom,
Lets see if I understand First there is an error check (On Error Resume Naxt) MkDir "C:\My Documents" triggers the error correct ? ( because it's there ) If this happens then the error is ran, (Resume Next) running this MkDir "C:\My Documents\Temp Me" ? ( because it's not there ) or it goes to 0 which exits sub ? ( because they both are there ) Am I on the right page ? Thanks again "Tom Ogilvy" wrote: Sub Auto_Open() On Error Resume Next MkDir "C:\My Documents" MkDir "C:\My Documents\Temp Me" On Error GoTo 0 End Sub -- Regards, Tom Ogilvy "Sgwapt" wrote in message ... Hello All, I am putting the finishing touches on my system and thought of having my Excel file automatically make the necessary folder on another users computer if it does not exist. This will allow them to make their report files using templates associated with command buttons they press at time of need. Currently I tried this in my Auto_Open module 'Dim Path As String 'Path = "C:\My Documents\Temp Me" 'If IsNot Path = Dir("C:\My Documents\Temp Me") Then MkDir ("C:\My Documents\Temp Me") 'Else 'Do nothing 'End If This makes the new folder but the next time it runs create and error. Obviously because it already is in place......LOL on me. What would be the correct Dim, and If statements I am looking for to make a directory that if is there "Do Nothing" else "Make It"? May have application flavor eh? Thanks for your help -- George G |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mk Dir
On Error Resume Next
means if there is an error ignore it, go to the next line On Error Goto zero sets error handling back to the default. so Create the directories. If they already exist, they will raise an error and be ignored. It they don't exist they will be created. -- Regards, Tom Ogilvy "Sgwapt" wrote in message ... Thanks Tom, Lets see if I understand First there is an error check (On Error Resume Naxt) MkDir "C:\My Documents" triggers the error correct ? ( because it's there ) If this happens then the error is ran, (Resume Next) running this MkDir "C:\My Documents\Temp Me" ? ( because it's not there ) or it goes to 0 which exits sub ? ( because they both are there ) Am I on the right page ? Thanks again "Tom Ogilvy" wrote: Sub Auto_Open() On Error Resume Next MkDir "C:\My Documents" MkDir "C:\My Documents\Temp Me" On Error GoTo 0 End Sub -- Regards, Tom Ogilvy "Sgwapt" wrote in message ... Hello All, I am putting the finishing touches on my system and thought of having my Excel file automatically make the necessary folder on another users computer if it does not exist. This will allow them to make their report files using templates associated with command buttons they press at time of need. Currently I tried this in my Auto_Open module 'Dim Path As String 'Path = "C:\My Documents\Temp Me" 'If IsNot Path = Dir("C:\My Documents\Temp Me") Then MkDir ("C:\My Documents\Temp Me") 'Else 'Do nothing 'End If This makes the new folder but the next time it runs create and error. Obviously because it already is in place......LOL on me. What would be the correct Dim, and If statements I am looking for to make a directory that if is there "Do Nothing" else "Make It"? May have application flavor eh? Thanks for your help -- George G |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|