+ Reply to Thread
Results 1 to 9 of 9

Macro to create a folder and then save all files in that folder

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Macro to create a folder and then save all files in that folder

    Hello,

    I have 14 sheets that open up automatically at different times of the day,pick up certain values form reuters and then save it to a folder.

    the whole process is automated.

    is there a logic by which..the first macro creates a folder with today date and then all remaining macros save the files to this folder.

    for ex: if we put a command to create a folder with datein first macro...how can i make that macro and remaining macros save file in the same folder.

    Sub SaveBook()
    Dim A As Integer
    Dim B As Integer
    Dim C As Integer
    Dim e As String
    Dim sFile As String
    With ActiveSheet.UsedRange
    .Value = .Value
    End With
    A = Day(Date) 'Day Value From Date
    B = Month(Date) 'Month Value From Date
    C = Year(Date) 'Year Value From Date
    e = A & "-" & B & "-" & C
    MkDir "Z:\Maker\" & e 'Make a Desired Folder By Current Date & Time
    sFile = "abcd" & " " & Format(Now(), "hh.mm") & ".xls"
    ActiveWorkbook.SaveAs Filename:="Z:\Maker\" & e & sFile
    ThisWorkbook.Close Saved = True
    End Sub

    this is will be my first macro...

    will i be able to do this?

    Thanks

    GOkz

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create a folder and then save all files in that folder

    you can put the new path in a public variable (declare it before sub statement), then use it for all saveas
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to create a folder and then save all files in that folder

    Hiii,,

    when i make the folder with a different public sub.

    how will i refer the folder name to my required macros?

    Thanks

    Gokz

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create a folder and then save all files in that folder

    Please Login or Register  to view this content.
    Last edited by patel45; 03-27-2013 at 09:08 AM.

  5. #5
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to create a folder and then save all files in that folder

    I have changed my macro a bit...

    Now my folder with name as date is created in the beginning with another sheet. tis folder will be created automatically first everyday.

    Now i want all the sheets that pop up later in the day to save as in that particular folder already created..

    for ex: my folder will be created in Z:\maker\24-03-2013\

    how can i refer to this folder from my other macros for everyday.

    Any advice would me much appreciated.

    Thanks

    Gokz

  6. #6
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to create a folder and then save all files in that folder

    Please Login or Register  to view this content.
    what changes should i make???

  7. #7
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create a folder and then save all files in that folder

    instead of Filename:="Z:\Maker\" & sFile use the path you created with other macro
    If in doubt paste it here

  8. #8
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to create a folder and then save all files in that folder

    the other macro is in a different workbook

    i created a folder using that macro.


    A = Day(Date) 'Day Value From Date
    B = Month(Date) 'Month Value From Date
    C = Year(Date) 'Year Value From Date
    e = A & "-" & B & "-" & C
    newpath= "Z:\Maker\" & e
    MkDir "Z:\Maker\" & e 'Make a Desired Folder By Current Date & Time

  9. #9
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create a folder and then save all files in that folder

    [QUOTE=gokzee;3174838]
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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