How To Find Path and Create a Folder with VB

  • Thread starter Thread starter Xcelsoft
  • Start date Start date
X

Xcelsoft

Hello all,

I have and Access 2k database that will transfer the
contents of a Table to a spreadsheet file using the
TransferSpreadSheet Method.

What I want to do is test before the DoCmd. method using
VB to see if a particular folder exist for
example "C:\MySpreadSheets". If this folder does not
exist, I want to create it before I run the
TransferSpreadSheet command.

Does anyone know the VB commands to test for the
existence of a file folder and the command to make a
folder using VB???

Any help will be appreciated.

Thanks
 
If Dir("C:\MySpreadSheets",vbDirectory") = "" Then
MkDir "C:\MySpreadSheets"
End If



Chris Nebinger
 
Xcelsoft said:
Hello all,

I have and Access 2k database that will transfer the
contents of a Table to a spreadsheet file using the
TransferSpreadSheet Method.

What I want to do is test before the DoCmd. method using
VB to see if a particular folder exist for
example "C:\MySpreadSheets". If this folder does not
exist, I want to create it before I run the
TransferSpreadSheet command.

Does anyone know the VB commands to test for the
existence of a file folder and the command to make a
folder using VB???

Any help will be appreciated.

Thanks

This Function verify if the Folder exist.
If not use MkDir DirPath$

so:

If not fIsFileDIR ("C:\FolderName\EventualSubFolder") then _
MkDir "C:\FolderName\EventualSubFolder"


Public Function fIsFileDIR(stPath As String, Optional lngType As Long) As
Integer
'*****************************************************************
'Name : fIsFileDIR (Function)
'Purpose : Verifie if File or Dir Exist
'Author : Alessandro Baraldi
'Called by :
'Calls :
'Inputs : To check for a file
' : fIsFileDIR("c:\winnt\win.ini")
' : To check for a Dir
' : fIsFileDir("c:\msoffice",vbdirectory)
'Output : True if Exist
'*****************************************************************
On Error Resume Next
fIsFileDIR = Len(Dir(stPath, lngType)) > 0
End Function

Bye.
 
Much appreciated.....

-----Original Message-----
"Xcelsoft" <[email protected]> ha scritto nel messaggio


This Function verify if the Folder exist.
If not use MkDir DirPath$

so:

If not fIsFileDIR ("C:\FolderName\EventualSubFolder") then _
MkDir "C:\FolderName\EventualSubFolder"


Public Function fIsFileDIR(stPath As String, Optional lngType As Long) As
Integer
'******************************************************** *********
'Name : fIsFileDIR (Function)
'Purpose : Verifie if File or Dir Exist
'Author : Alessandro Baraldi
'Called by :
'Calls :
'Inputs : To check for a file
' : fIsFileDIR("c:\winnt\win.ini")
' : To check for a Dir
' : fIsFileDir("c:\msoffice",vbdirectory)
'Output : True if Exist
'******************************************************** *********
On Error Resume Next
fIsFileDIR = Len(Dir(stPath, lngType)) > 0
End Function

Bye.
 
Does anyone know the VB commands to test for the
existence of a file folder
Dir

and the command to make a
folder using VB???

MkDir

Larry Linson
Microsoft Access MVP
 
Back
Top