Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ira ira is offline
external usenet poster
 
Posts: 1
Default How to check if the directory exists?

I try to save the file. I'd like to prevent the case when the path i
wrong - Temp directory doesn't exist - and show the warning by myself

ex. ThisWorkbook.SaveAs C:\Temp\1.xl

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default How to check if the directory exists?


"ira " wrote in message
...
I try to save the file. I'd like to prevent the case when the path is
wrong - Temp directory doesn't exist - and show the warning by myself.

ex. ThisWorkbook.SaveAs C:\Temp\1.xls


---
Message posted from http://www.ExcelForum.com/



You can use to the filesystem object and the folderexists method

Set fs = CreateObject("Scripting.FileSystemObject")

If fs.FolderExists("C:\Temp") Then
MsgBox "OK"
Else
MsgBox "not found"
End If

Set fs = Nothing

Keith


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to check if the directory exists?

Ira,

Use the DIR function

Dir("C:\Temp", vbDirectory)

it returns blank if the directory does not exist

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ira " wrote in message
...
I try to save the file. I'd like to prevent the case when the path is
wrong - Temp directory doesn't exist - and show the warning by myself.

ex. ThisWorkbook.SaveAs C:\Temp\1.xls


---
Message posted from http://www.ExcelForum.com/



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check to see if a value exists in a list? Pradhan Excel Worksheet Functions 6 April 2nd 23 06:35 PM
Check if file exists Jon Excel Discussion (Misc queries) 14 October 4th 07 04:57 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM
Check to see if cell value exists Mark Excel Programming 3 November 5th 03 03:20 PM
Verify a directory exists MacroMan[_4_] Excel Programming 3 August 8th 03 04:38 PM


All times are GMT +1. The time now is 03:55 PM.

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

About Us

"It's about Microsoft Excel"