![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 8
|
any help?
how can i have a macro that checks if a folder exists, if yes write a file to it ELSE does not exists, CREATE the folder then write a file to it. Thanks a million! Andrew |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 2002
Posts: 15
|
here is one way how you can make a folder
Sub FolderCheck() On Error GoTo ErrorCheck Dim FolderName As String FolderName = "c:barryTMP3" ChDir FolderName GoTo FolderCheckEnd ErrorCheck: If Err.Number = 76 Then GoTo MakeDir If Err.Number <> 76 Then MsgBox ("A Error happened while changing to " + FolderName + " or while making that folder and the error is " + Str(Err.Number)) End MakeDir: MkDir FolderName Resume FolderCheckEnd: End Sub i would probally use sub foldercheck(foldername as string) instead of sub foldercheck() and for saving the file you can just record a macro saving the file and modify it to meet your needs |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|