Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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
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



All times are GMT +1. The time now is 03:25 AM.

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

About Us

"It's about Microsoft Excel"