Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default MKDir not working

Here's my code:

UNITFOLDER = "G:\A F S\Monthly Reports\HiPath\CS\"
FILENAME = "MONTHLYC_"
NEWDIRECTORY = UNITFOLDER & RPTRUNDATE
If Dir(UNITFOLDER & RPTRUNDATE) = Null Then
MkDir (NEWDIRECTORY)
End If

Not sure why it's not working. It won't create the folder and I get an
error later. RPTRUNDATE is a variable (string) set earlier that in my
example I'm using "060206" as the string. I want it to first check if "G:\A
F S\Monthly Reports\HiPath\CS\060206" exists. If it doesn't, I want it to
create the folder. If it does exist, just keep going (earlier in the code I
delete any files in the directory).

Anyone have any idea why it's not working?

THX
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default MKDir not working

You will have to check if UNITFOLDER exists as you can't make
a new folder in non-existent folder. In other words you can't make
4 or 5 folders in one go, only one at a time.

RBS

"Robert_L_Ross" wrote in message
...
Here's my code:

UNITFOLDER = "G:\A F S\Monthly Reports\HiPath\CS\"
FILENAME = "MONTHLYC_"
NEWDIRECTORY = UNITFOLDER & RPTRUNDATE
If Dir(UNITFOLDER & RPTRUNDATE) = Null Then
MkDir (NEWDIRECTORY)
End If

Not sure why it's not working. It won't create the folder and I get an
error later. RPTRUNDATE is a variable (string) set earlier that in my
example I'm using "060206" as the string. I want it to first check if
"G:\A
F S\Monthly Reports\HiPath\CS\060206" exists. If it doesn't, I want it to
create the folder. If it does exist, just keep going (earlier in the code
I
delete any files in the directory).

Anyone have any idea why it's not working?

THX


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default MKDir not working

From one of Dave Peterson's old posts (which he reposted from Jim Rech). I
believe this API will create the folder and subfolders all in one go:


Declare Function MakePath Lib "imagehlp.dll" Alias _
"MakeSureDirectoryPathExists" (ByVal lpPath As String) As Long


Sub Test()
MakeDir "c:\aaa\bbb"
End Sub


Sub MakeDir(DirPath As String)
If Right(DirPath, 1) < "\" Then DirPath = DirPath & "\"
MakePath DirPath
End Sub




"RB Smissaert" wrote:

You will have to check if UNITFOLDER exists as you can't make
a new folder in non-existent folder. In other words you can't make
4 or 5 folders in one go, only one at a time.

RBS

"Robert_L_Ross" wrote in message
...
Here's my code:

UNITFOLDER = "G:\A F S\Monthly Reports\HiPath\CS\"
FILENAME = "MONTHLYC_"
NEWDIRECTORY = UNITFOLDER & RPTRUNDATE
If Dir(UNITFOLDER & RPTRUNDATE) = Null Then
MkDir (NEWDIRECTORY)
End If

Not sure why it's not working. It won't create the folder and I get an
error later. RPTRUNDATE is a variable (string) set earlier that in my
example I'm using "060206" as the string. I want it to first check if
"G:\A
F S\Monthly Reports\HiPath\CS\060206" exists. If it doesn't, I want it to
create the folder. If it does exist, just keep going (earlier in the code
I
delete any files in the directory).

Anyone have any idea why it's not working?

THX



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default MKDir not working

Thanks for the tip.

RBS

"JMB" wrote in message
...
From one of Dave Peterson's old posts (which he reposted from Jim Rech).
I
believe this API will create the folder and subfolders all in one go:


Declare Function MakePath Lib "imagehlp.dll" Alias _
"MakeSureDirectoryPathExists" (ByVal lpPath As String) As Long


Sub Test()
MakeDir "c:\aaa\bbb"
End Sub


Sub MakeDir(DirPath As String)
If Right(DirPath, 1) < "\" Then DirPath = DirPath & "\"
MakePath DirPath
End Sub




"RB Smissaert" wrote:

You will have to check if UNITFOLDER exists as you can't make
a new folder in non-existent folder. In other words you can't make
4 or 5 folders in one go, only one at a time.

RBS

"Robert_L_Ross" wrote in message
...
Here's my code:

UNITFOLDER = "G:\A F S\Monthly Reports\HiPath\CS\"
FILENAME = "MONTHLYC_"
NEWDIRECTORY = UNITFOLDER & RPTRUNDATE
If Dir(UNITFOLDER & RPTRUNDATE) = Null Then
MkDir (NEWDIRECTORY)
End If

Not sure why it's not working. It won't create the folder and I get an
error later. RPTRUNDATE is a variable (string) set earlier that in my
example I'm using "060206" as the string. I want it to first check if
"G:\A
F S\Monthly Reports\HiPath\CS\060206" exists. If it doesn't, I want it
to
create the folder. If it does exist, just keep going (earlier in the
code
I
delete any files in the directory).

Anyone have any idea why it's not working?

THX




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
mkdir command in excel 2003 on XP SP2 zvi carmi via OfficeKB.com New Users to Excel 2 May 25th 05 12:45 PM
MkDir and Save As wtpcomplab Excel Programming 2 December 9th 04 09:09 PM
mkdir problem Tom Ogilvy Excel Programming 2 August 31st 04 03:22 PM
mkdir problem Norman Jones Excel Programming 0 August 30th 04 04:37 PM
MkDir error Eric Excel Programming 3 May 17th 04 08:58 PM


All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"