Results 1 to 10 of 10

Code to create New Folder (if doesn't exist) and then Save Workbook to folder

Threaded View

  1. #1
    Registered User
    Join Date
    12-14-2012
    Location
    ohio
    MS-Off Ver
    Excel 2003
    Posts
    5

    Code to create New Folder (if doesn't exist) and then Save Workbook to folder

    Hello all,

    I am a newbie, so please be kind. I have been trying to correct this code for 2 days, and must admit I need help. I'm sure it's something simple, but can't crack it.

    I am using Excel 2007 and saving to a shared drive.

    I'm attempting to create a new folder, based on specific information in the workbook. If the folder already exists, I just need the workbook saved.
    The workbook also needs to be saved/named based on specific information in the workbook.

    The current code I have is:
    Sub SaveAs() Dim evnfol, newfol, sfile As String envfol = "\\MATTHEW-HP\Users\Matthew\Desktop\SCRATCH\Events\2013\" newfol = Format(CStr(Range("a13").Text), "mm.dd.yyyy") & Range("a9").Value & Range("b9").Value sfile = Format(CStr(Range("a13").Text), "mm.dd.yyyy") & Range("a9").Value & Range("b9").Value & Range("a11").Value If Len(Dir(envfol & newfol, vbDirectory)) = "" Then MkDir newfol End If ActiveWorkbook.SaveAs Filename:="envfol & newfol & " \ " & sfile", FileFormat:=52, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False End Sub
    Right now I'm receiving a error 13 type mismatch.
    Earlier today I was receving a error 1004 Method SaveAs of Workbook failed

    Thank you in advance for your assistance.
    Jenn
    Last edited by vlady; 01-07-2013 at 09:16 PM. Reason: code tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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