ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a way? (https://www.excelbanter.com/excel-programming/278782-there-way.html)

John Petty

Is there a way?
 
Is there a way to create a directory using Excel VBA?

I am asking because I want to have an application search
for a directory in the users "My Documents" and if it
doesn't exist, create one for the user to save files to.

Thanks,

John Petty

Don Guillett[_4_]

Is there a way?
 
This may give you an idea of how to go about it. This creates a backup in
any directory.

Sub Backup() 'kept in personal.xls & assigned to toolbar button
On Error GoTo BackupFile
MkDir CurDir & "\Backup"
BackupFile:
With ActiveWorkbook
MyWB = .Path & "\BACKUP\" & .Name
.SaveCopyAs MyWB
.Save
End With
End Sub

"John Petty" wrote in message
...
Is there a way to create a directory using Excel VBA?

I am asking because I want to have an application search
for a directory in the users "My Documents" and if it
doesn't exist, create one for the user to save files to.

Thanks,

John Petty




losmac

Is there a way?
 
MkDir("path")

Uzytkownik "John Petty" napisal w wiadomosci
...
Is there a way to create a directory using Excel VBA?

I am asking because I want to have an application search
for a directory in the users "My Documents" and if it
doesn't exist, create one for the user to save files to.

Thanks,

John Petty




Patrick Molloy[_4_]

Is there a way?
 
Ot may be worth taking a look at the Scripting Runtime DLL as this provides
the FileSystemObject that enables one to checke whether files/folder exist
etc

In the IDE, set a reference to MS Scripting Runtime and then take a look at
this code:

Sub CheckFolder()
Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject
Dim MyPath As String
MyPath = "C:\MyTempFolder"
If Not FSO.FolderExists(MyPath) Then
FSO.CreateFolder (MyPath)
End If
Set FSO = Nothing
End Sub

Its pretty simple. If you're folder is in fact a subfolder then you could
create in iteration to check if the parent folde exists too.

--
Patrick Molloy
----------------------------------
"John Petty" wrote in message
...
Is there a way to create a directory using Excel VBA?

I am asking because I want to have an application search
for a directory in the users "My Documents" and if it
doesn't exist, create one for the user to save files to.

Thanks,

John Petty





All times are GMT +1. The time now is 06:14 PM.

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