Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|