Consulting

Results 1 to 3 of 3

Thread: Creating a VBA Script to save in a current month's folder (create folder as needed)

  1. #1

    Creating a VBA Script to save in a current month's folder (create folder as needed)

    Hi All,

    I need some help with writing a VBA script in excel to do the following save file function

    1. the filename will have the following format "Cable SVL Page " & Format(Now, "mmmm dd, yyyy") & ".xlsm"
    2. The file will run from it's current location but will save as the above filename and format in a different location.
    3. The location to be saved in is "B:\NCC\ntsd\cable\" but the file will need to look for the current months' folder and save itself there.
    4. If the current months' folder does not exist it will need to be created before saving. The format of the month is just the full name of the month e.g. November.

    Any help will be appreciated.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Dim folder As String
    
        folder = "B:\NCC\ntsd\cable\" & Format(Date, "mmmm") & "\"
        On Error Resume Next
        MkDir folder
        On Error GoTo 0
        With ActiveWorkbook
        
            .SaveAs Filename:=folder & .Name
        End With
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks for your help.

    Works like a charm

Posting Permissions

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