Results 1 to 2 of 2

Check if Directory Exist

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Check if Directory Exist

    I'm trying to use an if statement to save a file to the temp directory, if it exist, and save it to the network drive it a temp dorectory doesn't exist.

    I think I'm close, but my searches in the forum didn't turn up anything to get me over the hump.

    Here's what I've got:
    If Exist "C:\Temp" Then
        ActiveWorkbook.SaveAs Filename:="C:\Temp\PO Response Tracking - Temp" & Format(Now, "hhmmss") & ".xls", _
            FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
            GoTo Temp
        Else
        ActiveWorkbook.SaveAs Filename:="M:\PO Response Tracking - Temp" & Format(Now, "hhmmss") & ".xls", _
            FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
        End If
    Thanks in advance for any help you can offer.

    Thanks, Kenneth. This worked:
    If Dir("C:\Temp", vbDirectory) = "" Then
        ActiveWorkbook.SaveAs Filename:="M:\PO Response Tracking - Temp" & Format(Now, "hhmmss") & ".xls", _
            FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
            GoTo Temp
        Else
        ActiveWorkbook.SaveAs Filename:="C:\Temp\PO Response Tracking - Temp" & Format(Now, "hhmmss") & ".xls", _
            FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
        End If
    Last edited by [email protected]; 10-02-2008 at 04:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Check Boxes & Linkedcell
    By MBigD011 in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 03-15-2010, 10:34 AM
  2. New file appears in directory, throws off whole script
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2008, 01:01 PM
  3. VBA; find string and copy
    By Bill Rudd in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-06-2008, 10:41 PM
  4. Check if files exist in a formula
    By dvent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2007, 08:18 PM
  5. Check Number of Files in Directory
    By dvent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2007, 10:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1