Check For A Folder & Create Folder :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Check For A Folder & Create Folder
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

markkramer
Board Regular


Joined: 09 May 2002
Posts: 75

Flag: Usa

Status: Offline

 Reply with quote  

Check For A Folder & Create Folder

Does anyone know how to check to see if a folder exists? If it doesn't then I'll create it using the MkDir command.

Thanks!

Mark

Post Fri Sep 19, 2003 5:25 pm 
 View user's profile Send private message

Iridium
Board Master
Board Master


Joined: 16 Jul 2002
Posts: 2581
Location: Walsall, England
Flag: England

Status: Offline

 Reply with quote  

Re: Check For A Folder & Create Folder

From the VBE help

FolderExists Method


Description

Returns True if a specified folder exists; False if it does not.

Syntax

object.FolderExists(folderspec)

The FolderExists method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
folderspec Required. The name of the folder whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the folder isn't expected to exist in the current folder.
_________________

Post Fri Sep 19, 2003 5:32 pm 
 View user's profile Send private message

markkramer
Board Regular


Joined: 09 May 2002
Posts: 75

Flag: Usa

Status: Offline

 Reply with quote  

Re: Check For A Folder & Create Folder

Thanks, Iridium.

I'm having some difficulty figuring out how to code it. Here's what I tried:

If Object.FolderExists("c:\temp") = False Then
MkDir "c:\temp"
End If

I receive a run-time error 424, Ojbect Required, error.

Any suggestions?

Mark

Post Fri Sep 19, 2003 5:40 pm 
 View user's profile Send private message

Ivan F Moala
MrExcel MVP


Joined: 11 Feb 2002
Posts: 3210
Location: Auckland, New Zealand
Flag: Newzealand

Status: Online

 Reply with quote  

That comand is part of the Filesystem Object
You will need to Add a reference to the SCRUN.dll

Microsoft scripting runtime
VBE Editor > Tools > Reference
_________________
Kind Regards,
Ivan F Moala From the City of Sails

Post Fri Sep 19, 2003 5:45 pm 
 View user's profile Send private message Send e-mail Visit poster's website

Iridium
Board Master
Board Master


Joined: 16 Jul 2002
Posts: 2581
Location: Walsall, England
Flag: England

Status: Offline

 Reply with quote  

Re: Check For A Folder & Create Folder

Have a search of the board using "folderexists" (without quotes)

One hit i got was

http://www.mrexcel.com/board2/viewtopic.php?t=48489&highlight=folderexists

HTH
_________________

Post Fri Sep 19, 2003 5:46 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.