ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create folder if it does not exists (https://www.excelbanter.com/excel-programming/327715-create-folder-if-does-not-exists.html)

Bob

Create folder if it does not exists
 
What coding can I use or what ways can I use so that each workbooks path is
unique, meaning that not one workbook path is the same e.g.
C:\220210\220210.xls, C:\220211\220211.xls...

Thanks
Bob

Bob Phillips[_6_]

Create folder if it does not exists
 
myNum = 220110

Do
fFound = fileexists("C:\220210\" & myNum & ".xls"
if fFiund Then myNum = myNum + 1
Loop Until Not fFound


Function FileExists(sFilename As String) As Boolean
FileExists = Dir(sFilename) < ""
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob" wrote in message
...
What coding can I use or what ways can I use so that each workbooks path

is
unique, meaning that not one workbook path is the same e.g.
C:\220210\220210.xls, C:\220211\220211.xls...

Thanks
Bob




AA2e72E

Create folder if it does not exists
 
Try:

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

MakeSureDirectoryPathExists "c:\abc\def\ghi\jkl\"

NOTE: Path must end with \

"Bob" wrote:

What coding can I use or what ways can I use so that each workbooks path is
unique, meaning that not one workbook path is the same e.g.
C:\220210\220210.xls, C:\220211\220211.xls...

Thanks
Bob


Barmaley

Create folder if it does not exists
 
Here is code I've been using to check if exist and create folder if not

Dim FsO As Object
Dim FolD As String

FolD = "your\folder\path\goes\here"
Set FsO = CreateObject("Scripting.FileSystemObject")
If Not FsO.FolderExists(FolD) Then FsO.CreateFolder (FolD)




"Bob" wrote in message
...
What coding can I use or what ways can I use so that each workbooks path

is
unique, meaning that not one workbook path is the same e.g.
C:\220210\220210.xls, C:\220211\220211.xls...

Thanks
Bob





All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com